diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 7a44cfef..8ad40e20 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -11,11 +11,11 @@ namespace CachetHQ\Cachet\Exceptions; -use CachetHQ\Cachet\Repositories\InvalidModelValidationException; use Exception; -use GrahamCampbell\Exceptions\ExceptionHandler as ExceptionHandler; +use GrahamCampbell\Exceptions\ExceptionHandler; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Facades\Response; +use Symfony\Component\HttpKernel\Exception\HttpNotFoundException; class Handler extends ExceptionHandler { @@ -25,7 +25,7 @@ class Handler extends ExceptionHandler * @var string[] */ protected $dontReport = [ - 'Symfony\Component\HttpKernel\Exception\HttpException', + HttpNotFoundException::class, ]; /** @@ -38,14 +38,8 @@ class Handler extends ExceptionHandler */ public function render($request, Exception $e) { - if ($request->is('api*')) { - if ($e instanceof InvalidModelValidationException) { - return Response::make(['status_code' => 400, 'message' => 'Bad Request'], 400); - } - - if ($e instanceof ModelNotFoundException) { - return Response::make(['status_code' => 404, 'error' => 'Resource not found'], 404); - } + if ($e instanceof ModelNotFoundException) { + $e = new HttpNotFoundException('Resource not found'); } return parent::render($request, $e);