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 ($e instanceof RedirectException) {
         return redirect($e->getTarget())->with('messages', $e->toArray());
     }
     if (!$this->isHttpException($e) && !config('app.debug')) {
         return response()->view('errors.500', [], 500);
     }
     return parent::render($request, $e);
 }
Beispiel #2
0
 /**
  * Throw a new exception
  * @param string|array $msg Exception Message
  */
 public function __construct($msg = 'An error occured', $code = 0)
 {
     if (is_array($msg)) {
         $msg = implode($msg, ' ');
     }
     parent::__construct($msg, $code);
 }
 public function __construct(MessageBag $messages = null)
 {
     parent::__construct("An error occured");
     $this->messages = $messages;
     if (is_null($this->messages)) {
         $this->messages = new MessageBag();
     }
 }
 /**
  * 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->response = app(Response::class);
     // Model not found
     if ($e instanceof ModelNotFoundException) {
         return $this->response->errorNotFound(['title' => 'No query results', 'code' => Error::CODE_RESOURCE_NOT_FOUND]);
     }
     // Wrongs argument
     if ($e instanceof InvalidArgumentException) {
         return $this->response->errorWrongArgs([$e->getMessage()]);
     }
     // Validator
     if ($e instanceof ValidatorException) {
         return $this->response->errorWrongArgsValidator($e->errors());
     }
     if ($e instanceof AuthorizationException) {
         return $this->response->errorUnauthorized([$e->getMessage()]);
     }
     // Route not found
     if ($e instanceof NotFoundHttpException) {
         return $this->response->errorNotFound();
     }
     //  Method not allowed
     if ($e instanceof MethodNotAllowedHttpException) {
         return $this->response->errorMethodNotAllowed();
     }
     if ($e instanceof InvalidRequestException) {
         return $this->response->errorUnauthorized([$e->getMessage()]);
     }
     if ($e instanceof AccessDeniedException) {
         return $this->response->errorUnauthorized([$e->getMessage()]);
     }
     return parent::render($request, $e);
 }
Beispiel #5
0
 /**
  * @param Release $release
  * @param string $message
  */
 public function __construct(Release $release, $message = "")
 {
     parent::__construct($message, 0);
     $this->release = $release;
 }
 public function __construct($message = 'Resource Not Found', $code = 0, \Exception $previous = null)
 {
     parent::__construct($message, $code, $previous);
 }