6
0
Fork 0

短信网关异常处理

release
李静 2021-12-31 20:33:47 +08:00
parent e91ae242d7
commit 557888392c
1 changed files with 9 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Throwable;
@ -64,6 +65,14 @@ class Handler extends ExceptionHandler
return new HttpException(404, __(':resource not found', ['resource' => $resource]), $e);
});
$this->reportable(function (NoGatewayAvailableException $e) {
foreach ($e->getExceptions() as $exception) {
$this->report($exception);
}
return false;
});
$this->renderable(function (BizException $e, $request) {
if ($this->shouldReturnJson($request, $e)) {
return response()->json($this->convertExceptionToArray($e), $e->status);