getMessage(), $e); } if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('remote/*')) { $exception = 'An exception occured while attempting to perform this action, please try again.'; if ($e instanceof DisplayException) { $exception = $e->getMessage(); } // Live environment, just return a nice error. if(!env('APP_DEBUG', false)) { return response()->json([ 'error' => $exception ], 500); } // If we are debugging, return the exception in it's full manner. return response()->json([ 'error' => (empty($e->getMessage())) ? $exception : $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace(), ], 500); } return parent::render($request, $e); } /** * 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('/auth/login'); } }