From a8cbac9dcc212797d82ed703ee7bf1258a7bc1a8 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 27 Sep 2024 14:20:56 -0400 Subject: [PATCH] Rename message property to error in RpcError class --- src/Socialbox/Objects/RpcError.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Socialbox/Objects/RpcError.php b/src/Socialbox/Objects/RpcError.php index d8a2d9c..99694d4 100644 --- a/src/Socialbox/Objects/RpcError.php +++ b/src/Socialbox/Objects/RpcError.php @@ -8,21 +8,30 @@ use Socialbox\Interfaces\SerializableInterface; class RpcError implements SerializableInterface { private string $id; - private string $message; + private string $error; private StandardError $code; /** * Constructs the RPC error object. * * @param string $id The ID of the RPC request - * @param StandardError $error The error code - * @param string $message The error message + * @param StandardError $code The error code + * @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->code = $error; - $this->message = $message; + $this->code = $code; + + if($error === null) + { + $this->error = $code->getMessage(); + } + else + { + $this->error = $error; + } + } /** @@ -40,9 +49,9 @@ class RpcError implements SerializableInterface * * @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 [ 'id' => $this->id, - 'error' => $this->message, + 'error' => $this->error, 'code' => $this->code->value ]; }