diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 0dafbc96e..ed7c004b2 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -11,6 +11,7 @@ use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Pterodactyl\Exceptions\Model\DataValidationException; use Symfony\Component\HttpKernel\Exception\HttpException; +use Pterodactyl\Exceptions\Repository\RecordNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler @@ -28,6 +29,7 @@ class Handler extends ExceptionHandler DisplayValidationException::class, HttpException::class, ModelNotFoundException::class, + RecordNotFoundException::class, TokenMismatchException::class, ValidationException::class, ]; @@ -69,7 +71,7 @@ class Handler extends ExceptionHandler $response = response()->json( [ 'error' => $displayError, - 'http_code' => (! $this->isHttpException($exception)) ?: $exception->getStatusCode(), + 'http_code' => (method_exists($exception, 'getStatusCode')) ? $exception->getStatusCode() : 500, 'trace' => (! config('app.debug')) ? null : $exception->getTrace(), ], $this->isHttpException($exception) ? $exception->getStatusCode() : 500, diff --git a/app/Exceptions/Repository/RecordNotFoundException.php b/app/Exceptions/Repository/RecordNotFoundException.php index 796b4c083..7a3aa093e 100644 --- a/app/Exceptions/Repository/RecordNotFoundException.php +++ b/app/Exceptions/Repository/RecordNotFoundException.php @@ -26,4 +26,11 @@ namespace Pterodactyl\Exceptions\Repository; class RecordNotFoundException extends \Exception { + /** + * @return int + */ + public function getStatusCode() + { + return 404; + } }