Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TryCatchMiddleware #15

Closed
wants to merge 0 commits into from

Conversation

2 participants
@mabar
Copy link
Member

commented Jun 25, 2018

  • TryCatchMiddleware (Closes #14)
  • Updated phpstan
  • better typehints (should not be BC breaking)

@mabar mabar requested a review from f3l1x Jun 25, 2018

public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
{
if ($this->enable) {

This comment has been minimized.

Copy link
@f3l1x

f3l1x Jun 25, 2018

Member

It needs to be rewritten, as we discussed.

This comment has been minimized.

Copy link
@mabar

mabar Jun 26, 2018

Author Member

Done.

@mabar mabar force-pushed the try-catch-middleware branch from e90eab1 to 9efd577 Jun 26, 2018

try {
return $next($request, $response);
} catch (Throwable $throwable) {
echo sprintf('Application encountered an internal error with status code "500" and with message "%s".', $throwable->getMessage());

This comment has been minimized.

Copy link
@f3l1x

f3l1x Jun 26, 2018

Member

Well, please set this text back to response and set the status code to 500 also into response.

return $next($request, $response);
} catch (Throwable $throwable) {
echo sprintf('Application encountered an internal error with status code "500" and with message "%s".', $throwable->getMessage());
exit($throwable->getCode());

This comment has been minimized.

Copy link
@f3l1x

f3l1x Jun 26, 2018

Member

You can't break the circle here.

@mabar mabar closed this Jun 28, 2018

@mabar mabar force-pushed the try-catch-middleware branch from 9efd577 to 0ac059a Jun 28, 2018

@f3l1x f3l1x deleted the try-catch-middleware branch Jun 28, 2018

@f3l1x f3l1x restored the try-catch-middleware branch Jun 28, 2018

@mabar mabar deleted the try-catch-middleware branch Jun 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.