Skip to content

Commit

Permalink
PsrLogErrorHandler: use in logs message of original exception instead…
Browse files Browse the repository at this point in the history
… of ApiException
  • Loading branch information
mabar authored and f3l1x committed Sep 24, 2019
1 parent 43f6fde commit d6d0a6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ErrorHandler/PsrLogErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function handle(Throwable $error): ApiResponse
if ($error instanceof ApiException && ($previous = $error->getPrevious()) !== null) {
// Server error is expected to contain a real error while client error can contain just information, why client request failed
$level = $error instanceof ServerErrorException ? LogLevel::ERROR : LogLevel::DEBUG;
$this->logger->log($level, $error->getMessage(), ['exception' => $previous]);
$this->logger->log($level, $previous->getMessage(), ['exception' => $previous]);
}

return parent::handle($error);
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/ErrorHandler/PsrLogErrorHandler.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ test(function (): void {
[
[
'level' => 'debug',
'message' => 'client',
'message' => 'test',
'context' => [
'exception' => $previousError,
],
],
[
'level' => 'error',
'message' => 'server',
'message' => 'test',
'context' => [
'exception' => $previousError,
],
Expand Down

0 comments on commit d6d0a6b

Please sign in to comment.