Skip to content

Commit f292080

Browse files
committed
Should close pterodactyl#244
What a peculiar bug. Also modifies code to try and return the correct status code, as well as return JSON based errors on any request that Laravel thinks should have a JSON based response.
1 parent 8323477 commit f292080

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

app/Exceptions/Handler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ public function report(Exception $exception)
4646
*/
4747
public function render($request, Exception $exception)
4848
{
49-
if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('remote/*')) {
49+
if ($request->expectsJson()) {
5050
$response = response()->json([
5151
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.',
52-
], 500);
52+
], ($this->isHttpException($exception)) ? $e->getStatusCode() : 500);
5353

54-
// parent::render() will log it, we are bypassing it in this case.
55-
Log::error($exception);
54+
parent::report($exception);
5655
}
5756

5857
return (isset($response)) ? $response : parent::render($request, $exception);

0 commit comments

Comments
 (0)