> */ protected $dontReport = [ ApiException::class, ]; /** * A list of the inputs that are never flashed for validation exceptions. * * @var array */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * @param Throwable $e * @return void * @throws Throwable */ public function report(Throwable $e) { $appEnv = env('APP_ENV', 'production'); $appName = env('APP_NAME', '未设置项目名'); if ($appEnv === 'production' && $this->shouldReport($e)) { $date = date('Y-m-d H:i:s'); $file = $e->getFile(); $line = $e->getLine(); $message = $e->getMessage(); $trace = $e->getTraceAsString(); $traceArr = explode('#', $trace); $traceSimple = $trace; if (is_array($traceArr)) { $traceSub = array_slice($traceArr, 0, 3); $traceSimple = implode('#', $traceSub); } $msg = <<reportable(function (Throwable $e) { // }); $this->renderable(function(Exception $e, $request) { return $this->handleException($request, $e); }); } private function handleException($request, Exception $e) { if ($e instanceof ApiException) { $data = [ 'code' => $e->getCode(), 'msg' => $e->getMessage(), 'data' => (Object)[] ]; return response()->json($data); } return null; } }