Cleanup exception handler

This commit is contained in:
Graham Campbell
2015-03-30 21:47:25 +01:00
parent 64f5c23546
commit 3f0b2d1375

View File

@@ -1,7 +1,9 @@
<?php namespace CachetHQ\Cachet\Exceptions;
use CachetHQ\Cachet\Repositories\InvalidModelValidationException;
use Exception;
use GrahamCampbell\Exceptions\ExceptionHandler as ExceptionHandler;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Response;
class Handler extends ExceptionHandler
@@ -15,20 +17,6 @@ class Handler extends ExceptionHandler
'Symfony\Component\HttpKernel\Exception\HttpException',
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
*
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
@@ -40,11 +28,11 @@ class Handler extends ExceptionHandler
public function render($request, Exception $e)
{
if ($request->is('api*')) {
if ($e instanceof \CachetHQ\Cachet\Repositories\InvalidModelValidationException) {
if ($e instanceof InvalidModelValidationException) {
return Response::make(['status_code' => 400, 'message' => 'Bad Request'], 400);
}
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
if ($e instanceof ModelNotFoundException) {
return Response::make(['status_code' => 404, 'error' => 'Resource not found'], 404);
}
}