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

Commit

Permalink
Merge branch 'hotfix/39'
Browse files Browse the repository at this point in the history
Close #39
  • Loading branch information
weierophinney committed Mar 17, 2016
2 parents e513ac9 + 066447e commit 9787d52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ details.

### Fixed

- Nothing.
- [#39](https://github.com/zendframework/zend-stratigility/pull/39) updates the
FinalHandler to ensure that emitted exception messages include previous
exceptions.

## 1.1.2 - 2015-10-09

Expand Down
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 9787d52

Please sign in to comment.