laminas / laminas-json-server

Laminas Json-Server is a JSON-RPC server implementation.
https://docs.laminas.dev/laminas-json-server/
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

Allow omitting of error data value as specified in JSON-RPC 2.0 #1

Closed arueckauer closed 4 years ago

arueckauer commented 4 years ago
Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA no

Description

This PR allows omitting the data value of an error object as specified in JSON-RPC 2.0

data A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).

How do you reproduce it?

$response = new Laminas\Json\Server\Response();
$response->setOptions([
    'error' => [
        'code' => 0,
        'message' => 'Lorem Ipsum',
    ],
]);

What did you expect to happen?

That the error object (array) is parsed correctly although data is omitted.

What actually happened?

setOptions() fails with an error.

Notice: Undefined index: data in vendor/laminas/laminas-json-server/src/Response.php on line 67