Skip to content

Commit 1616cf1

Browse files
committed
Always show errors from HTTP exceptions correctly to the user; closes pterodactyl#2439
1 parent f31a6d3 commit 1616cf1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/Exceptions/Handler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\HttpKernel\Exception\HttpException;
1818
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
1919
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
20+
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
2021

2122
class Handler extends ExceptionHandler
2223
{
@@ -217,7 +218,9 @@ public static function convertToArray(Throwable $exception, array $override = []
217218
'status' => method_exists($exception, 'getStatusCode')
218219
? strval($exception->getStatusCode())
219220
: ($exception instanceof ValidationException ? '422' : '500'),
220-
'detail' => 'An error was encountered while processing this request.',
221+
'detail' => $exception instanceof HttpExceptionInterface
222+
? $exception->getMessage()
223+
: 'An unexpected error was ecnountered while processing this request, please try again.',
221224
];
222225

223226
if ($exception instanceof ModelNotFoundException || $exception->getPrevious() instanceof ModelNotFoundException) {

0 commit comments

Comments
 (0)