Commit 252bc6c1 authored by zhoujun's avatar zhoujun

异常处理

parent dcb2919d
......@@ -3,6 +3,8 @@
namespace App\Exceptions;
use Illuminate\Session\TokenMismatchException;
use Psy\Exception\ErrorException;
use Illuminate\Database\QueryException;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
......@@ -54,9 +56,16 @@ class Handler extends ExceptionHandler
if ($exception instanceof TokenMismatchException) {
$exception = new TokenMismatchException("网络异常,请稍后刷新重试");
}
if ($exception instanceof \ErrorException) {
return redirect(route("login"));
if ($exception instanceof QueryException) {
return new JsonResponse(['error' => 5001, 'message' => '网络错误']);
}
if ($exception instanceof ErrorException) {
return redirect(route('index'));
}
return parent::render($request, $exception);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment