Commit a5e79bed by 杨昕

添加处理自定义异常

parent d61c9920
Pipeline #14303 passed with stages
in 4 minutes 18 seconds
......@@ -76,18 +76,21 @@ class Handler extends ExceptionHandler
}
}
/**
* 处理自定义异常
*/
if (self::handlerException($exception)) {
# 获取常量类里面的异常常量
$message = json_decode($exception->getMessage(),true);
return error(...$message);
}
if ($request->is('api/*') ) {
/**
* Api异常处理模块
*/
if (self::handlerException($exception)) {
# 获取常量类里面的异常常量
$message = json_decode($exception->getMessage(),true);
return error(...$message);
} else if ($exception instanceof AuthenticationException) {
if ($exception instanceof AuthenticationException) {
return error($exception->getMessage(),\Symfony\Component\HttpFoundation\Response::HTTP_UNAUTHORIZED);
} else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) {
return error('请求方法不被允许',\Symfony\Component\HttpFoundation\Response::HTTP_METHOD_NOT_ALLOWED);
......@@ -113,6 +116,9 @@ class Handler extends ExceptionHandler
}else{
return response()->view('errors.404');
}
//return error($exception->getMessage());
#return response()->json(['code'=>403, 'msg'=>'您没有权限']);
}
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