Skip to content

Commit aaa5cd8

Browse files
committed
Added human-readable message to an error response, reflecting high-level reason of the error.
1 parent d264d93 commit aaa5cd8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

JsonRpcError.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ public function __construct(\Exception $exception)
2626
{
2727
$this->code = $exception->getCode();
2828
$this->message = $this->getExceptionMessage($exception);
29+
$this->data = [];
2930

3031
if (defined('YII_DEBUG') && YII_DEBUG) {
3132
$this->data = $this->convertExceptionToArray($exception);
3233
}
34+
35+
// We need to provide client with an original error message
36+
$this->data['human_message'] = ($exception->getPrevious()) ? $exception->getPrevious()->getMessage() : $exception->getMessage();
3337
}
3438

3539
/**

0 commit comments

Comments
 (0)