diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-03 22:43:19 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-03 22:55:54 +0200 |
commit | 36dafdb68acbde2fe42ce36ef50f497c8c06411f (patch) | |
tree | 1e420597ae72c979361bf29b66ae7e27c73cf431 /src/Exceptions | |
parent | 9f1ee0c6c6497d43fb275491ec53fda420f64b81 (diff) | |
parent | b0e7bc0df2eb4975223582089c7a928903e8cd14 (diff) |
Merge remote-tracking branch 'MyIgel/rebuild-psr7'
Diffstat (limited to 'src/Exceptions')
-rw-r--r-- | src/Exceptions/Handler.php | 17 | ||||
-rw-r--r-- | src/Exceptions/Handlers/Whoops.php | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 6b3300e6..b3d840c0 100644 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -54,8 +54,10 @@ class Handler /** * @param Throwable $e + * @param bool $return + * @return string */ - public function exceptionHandler($e) + public function exceptionHandler($e, $return = false) { if (!$this->request instanceof Request) { $this->request = new Request(); @@ -63,8 +65,21 @@ class Handler $handler = $this->handler[$this->environment]; $handler->report($e); + ob_start(); $handler->render($this->request, $e); + + if ($return) { + $output = ob_get_contents(); + ob_end_clean(); + return $output; + } + + http_response_code(500); + ob_end_flush(); + $this->terminateApplicationImmediately(); + + return ''; } /** diff --git a/src/Exceptions/Handlers/Whoops.php b/src/Exceptions/Handlers/Whoops.php index 73352105..630aca1d 100644 --- a/src/Exceptions/Handlers/Whoops.php +++ b/src/Exceptions/Handlers/Whoops.php @@ -34,6 +34,8 @@ class Whoops extends Legacy implements HandlerInterface $whoops = $this->app->make(WhoopsRunner::class); $handler = $this->getPrettyPageHandler($e); $whoops->pushHandler($handler); + $whoops->writeToOutput(false); + $whoops->allowQuit(false); if ($request->isXmlHttpRequest()) { $handler = $this->getJsonResponseHandler(); |