getMessage(); } else { $message = $exception->getPrevious()->getMessage(); } if (in_array($exception->getCode(), [1044, 1045, 2002])) { throw new DatabaseConnectException($message, $exception->getCode(), $exception); } return response('Unhandled MySQL Error [' . $exception->getCode() . "] $message"); } // emulate Laravel 5.5 renderable exceptions if (method_exists($exception, 'render')) { return $exception->render($request); } if (config('app.debug')) { return parent::render($request, $exception); } return view('errors.generic')->with('exception', $exception); } /** * Convert an authentication exception into an unauthenticated response. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } return redirect()->guest(route('login')); } }