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' into develop
Browse files Browse the repository at this point in the history
Forward port #39
  • Loading branch information
weierophinney committed Mar 17, 2016
2 parents 4f13e7b + 066447e commit e580c57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ errors. Starting with 1.2.0, they now raise a `RuntimeException`.

### Added

- Nothing.
- [#36](https://github.com/zendframework/zend-stratigility/pull/36) adds a new
`InvalidMiddlewareException`, with the static factory `fromValue()` that
provides an exception message detailing the invalid type. `MiddlewarePipe` now
throws this exception from the `pipe()` method when a non-callable value is
provided.

### Deprecated

Expand All @@ -35,11 +39,7 @@ errors. Starting with 1.2.0, they now raise a `RuntimeException`.

### Added

- [#36](https://github.com/zendframework/zend-stratigility/pull/36) adds a new
`InvalidMiddlewareException`, with the static factory `fromValue()` that
provides an exception message detailing the invalid type. `MiddlewarePipe` now
throws this exception from the `pipe()` method when a non-callable value is
provided.
- Nothing.

### Deprecated

Expand All @@ -51,7 +51,9 @@ errors. Starting with 1.2.0, they now raise a `RuntimeException`.

### 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 e580c57

Please sign in to comment.