mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
Set Whoops middleware HTTP status to error code (#1648)
* Use error code for HTTP status, defaults to 500 * Use logic from HandleErrorsWithView, make sure status is valid
This commit is contained in:
parent
7e0855d9da
commit
aa442f2cb8
|
@ -42,11 +42,19 @@ class HandleErrorsWithWhoops implements Middleware
|
||||||
try {
|
try {
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
if ($e->getCode() !== 404) {
|
$status = 500;
|
||||||
|
$errorCode = $e->getCode();
|
||||||
|
|
||||||
|
if ($errorCode !== 404) {
|
||||||
$this->logger->error($e);
|
$this->logger->error($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return WhoopsRunner::handle($e, $request);
|
if (is_int($errorCode) && $errorCode >= 400 && $errorCode < 600) {
|
||||||
|
$status = $errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WhoopsRunner::handle($e, $request)
|
||||||
|
->withStatus($status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user