Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Final handler return prev exceptions in development mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Witold Wasiczko committed Dec 30, 2015
1 parent 61adbe7 commit d56bbdf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/FinalHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ private function create404(RequestInterface $request, ResponseInterface $respons
private function createDevelopmentErrorMessage($error)
{
if ($error instanceof Exception) {
$message = $error->getMessage() . "\n";
$message .= $error->getTraceAsString();
$message = $error;
} elseif (is_object($error) && ! method_exists($error, '__toString')) {
$message = sprintf('Error of type "%s" occurred', get_class($error));
} else {
Expand Down
12 changes: 12 additions & 0 deletions test/FinalHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ public function testInvokingWithExceptionInNonProductionModeIncludesTraceInRespo
$this->assertContains($expected, (string) $response->getBody());
}

public function testInvokingWithExceptionInNonProductionModeIncludesPrevTraceInResponseBody()
{
$prev = new \Exception('boobar', 500);
$error = new Exception('foo', 400, $prev);
$response = call_user_func($this->final, $this->request, $this->response, $error);
$expected = $this->escaper->escapeHtml($error->getTraceAsString());
$body = (string) $response->getBody();
$this->assertContains($expected, $body);
$this->assertContains('boobar', $body);
$this->assertContains('foo', $body);
}

public function testInvokingWithErrorInProductionSetsResponseToReasonPhrase()
{
$final = new FinalHandler([
Expand Down

0 comments on commit d56bbdf

Please sign in to comment.