generated from liutk/owl-admin-base
Compare commits
No commits in common. "7c755b9072bfa3e0514a2da784c9aa9fe9614496" and "776842c376495e3293ad12bebf1639809dd576b7" have entirely different histories.
7c755b9072
...
776842c376
|
|
@ -4,11 +4,9 @@ namespace App\Exceptions;
|
||||||
|
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\{Request};
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
||||||
use Illuminate\Auth\AuthenticationException;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
|
|
@ -36,10 +34,6 @@ class Handler extends ExceptionHandler
|
||||||
$this->renderable(function (RuntimeException $e, Request $request) {
|
$this->renderable(function (RuntimeException $e, Request $request) {
|
||||||
return response(['code' => $e->getCode(), 'message' => $e->getMessage()], $e->getHttpStatusCode());
|
return response(['code' => $e->getCode(), 'message' => $e->getMessage()], $e->getHttpStatusCode());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->renderable(function (NotFoundHttpException $e, Request $request) {
|
|
||||||
return response(['code' => Response::HTTP_NOT_FOUND, 'message' => $e->getMessage()], Response::HTTP_NOT_FOUND);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function invalidJson($request, ValidationException $exception)
|
protected function invalidJson($request, ValidationException $exception)
|
||||||
|
|
@ -50,11 +44,4 @@ class Handler extends ExceptionHandler
|
||||||
'errors' => $exception->errors(),
|
'errors' => $exception->errors(),
|
||||||
], $exception->status);
|
], $exception->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function unauthenticated($request, AuthenticationException $exception)
|
|
||||||
{
|
|
||||||
return $this->shouldReturnJson($request, $exception)
|
|
||||||
? response()->json(['code' => Response::HTTP_UNAUTHORIZED, 'message' => $exception->getMessage()], 401)
|
|
||||||
: redirect()->guest($exception->redirectTo() ?? route('login'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue