no message

This commit is contained in:
kuaifan
2021-05-29 22:13:58 +08:00
parent 8e770b02fe
commit f99f46efbb
12 changed files with 295 additions and 134 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Exceptions;
use App\Module\Base;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
@@ -38,4 +40,19 @@ class Handler extends ExceptionHandler
//
});
}
/**
* 将异常转换为 HTTP 响应。
* @param $request
* @param Throwable $e
* @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* @throws Throwable
*/
public function render($request, Throwable $e)
{
if ($e instanceof ModelNotFoundException) {
return response()->json(Base::retError('数据不存在!'));
}
return parent::render($request, $e);
}
}