Rename message property to error in RpcError class

This commit is contained in:
netkas 2024-09-27 14:20:56 -04:00
parent bc6555e559
commit a8cbac9dcc

View file

@ -8,21 +8,30 @@ use Socialbox\Interfaces\SerializableInterface;
class RpcError implements SerializableInterface class RpcError implements SerializableInterface
{ {
private string $id; private string $id;
private string $message; private string $error;
private StandardError $code; private StandardError $code;
/** /**
* Constructs the RPC error object. * Constructs the RPC error object.
* *
* @param string $id The ID of the RPC request * @param string $id The ID of the RPC request
* @param StandardError $error The error code * @param StandardError $code The error code
* @param string $message The error message * @param string $error The error message
*/ */
public function __construct(string $id, StandardError $error, string $message) public function __construct(string $id, StandardError $code, ?string $error)
{ {
$this->id = $id; $this->id = $id;
$this->code = $error; $this->code = $code;
$this->message = $message;
if($error === null)
{
$this->error = $code->getMessage();
}
else
{
$this->error = $error;
}
} }
/** /**
@ -40,9 +49,9 @@ class RpcError implements SerializableInterface
* *
* @return string The error message. * @return string The error message.
*/ */
public function getMessage(): string public function getError(): string
{ {
return $this->message; return $this->error;
} }
/** /**
@ -64,7 +73,7 @@ class RpcError implements SerializableInterface
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'error' => $this->message, 'error' => $this->error,
'code' => $this->code->value 'code' => $this->code->value
]; ];
} }