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

Final handler return prev exceptions in development mode #39

Merged
merged 1 commit into from
Mar 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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