Beispiel #1
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if (config('app.debug') === false) {
         return $this->handleExceptions($e);
     }
     return parent::render($request, $e);
 }
Beispiel #2
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     return parent::render($request, $e);
 }
Beispiel #3
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof NotFoundHttpException) {
         return response()->view('errors.404');
     }
     return parent::render($request, $e);
 }
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     // This currenty disable the correct working of abort();
     // for example this page: http://suaray.com/events/5651/schedules
     // yields a 401, when this is uncommented, it just will show th 500 error page
     // if (app()->environment() == 'production') {
     //     return response()->view('errors.500', [], 500);
     // }
     return parent::render($request, $e);
 }
Beispiel #5
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception                $exception
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $exception)
 {
     if ($this->isHttpException($exception)) {
         return $this->renderHttpException($exception);
     }
     if (config('app.debug')) {
         return $this->renderExceptionWithWhoops($exception);
     }
     return parent::render($request, $exception);
 }
Beispiel #6
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     /*        if ($e instanceof NotFoundHttpException){
                 return response()->json(['message' => 'Bad request, please verify request route','code'=>400],400);
             }
             else {
                 return response()->json(['message'=>'Unexpected error, try again later', 'code'=>450], 50'');
             }
             else
     */
     return parent::render($request, $e);
 }
Beispiel #7
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     return parent::render($request, $e);
 }
Beispiel #8
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     $prefix = !is_null($request->route()) ? $request->route()->getAction()['prefix'] : NULL;
     if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
         if ($prefix != '/api/v1') {
             Flash::danger('The resource you are looking for could not be found.');
             return response()->view('errors.404', array(), 404);
         } else {
             return response()->json(['error' => 'Resource not found'], 400);
         }
     }
     if ($e instanceof \App\Exceptions\LambdaException && getenv('APP_ENV') !== 'local') {
         Flash::danger('An error occurred: ' . $e->getMessage());
         Log::error($e->getPrevious());
         return redirect()->home();
     }
     if ($e instanceof \PDOException) {
         return response()->view('errors.500');
     }
     if ($request->wantsJson()) {
         // Define the response
         $response = ['errors' => 'Sorry, something went wrong.'];
         // If the app is in debug mode
         if (config('app.debug')) {
             // Add the exception class name, message and stack trace to response
             $response['exception'] = get_class($e);
             // Reflection might be better here
             $response['message'] = $e->getMessage();
             $response['trace'] = $e->getTrace();
         }
         // Default response of 400
         $status = 400;
         // If this exception is an instance of HttpException
         if ($this->isHttpException($e)) {
             // Grab the HTTP status code from the Exception
             $status = $e->getStatusCode();
         }
         // Return a JSON response with the response array and status code
         return response()->json($response, $status);
     }
     if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
         return response()->json(['Token expired'], $e->getStatusCode());
     } else {
         if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
             return response()->json(['Token invalid'], $e->getStatusCode());
         }
     }
     return parent::render($request, $e);
 }