当前位置: 首页>>代码示例>>PHP>>正文


PHP Handler::render方法代码示例

本文整理汇总了PHP中Illuminate\Foundation\Exceptions\Handler::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Handler::render方法的具体用法?PHP Handler::render怎么用?PHP Handler::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Foundation\Exceptions\Handler的用法示例。


在下文中一共展示了Handler::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param Request   $request
  * @param Exception $exception
  *
  * @return Response
  */
 public function render($request, Exception $exception)
 {
     if (!$request->is(config('jsonapi.url'))) {
         return parent::render($request, $exception);
     }
     return $this->handle($request, $exception);
 }
开发者ID:askedio,项目名称:laravel-cruddy,代码行数:15,代码来源:Handler.php

示例2: render

 /**
  * 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)
 {
     switch (get_class($e)) {
         case "Swift_TransportException":
         case "PDOException":
             $errorView = "errors.500_config";
             break;
         case "ErrorException":
             $errorView = "errors.500";
             break;
         case "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException":
             return abort(400);
         default:
             $errorView = false;
             break;
     }
     if ($errorView) {
         // This makes use of a Symfony error handler to make pretty traces.
         $SymfonyDisplayer = new SymfonyDisplayer(config('app.debug'));
         $FlattenException = FlattenException::create($e);
         $SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException);
         $SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException);
         $response = response()->view($errorView, ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500);
         return $this->toIlluminateResponse($response, $e);
     } else {
         return parent::render($request, $e);
     }
 }
开发者ID:RustyGamer,项目名称:infinity-next,代码行数:35,代码来源:Handler.php

示例3: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     switch ($e) {
         case $e instanceof NotFoundHttpException:
             return $this->renderException($e);
             break;
         case $e instanceof ModelNotFoundException:
             return $this->renderException($e);
             break;
         case $e instanceof UnauthorizedException:
             return $this->renderException($e);
             break;
         case $e instanceof NoActiveAccountException:
             return $this->renderException($e);
             break;
         case $e instanceof ConnectionNotAcceptedException:
             return $this->renderException($e);
             break;
         case $e instanceof EmailNotProvidedException:
             return $this->renderException($e);
             break;
         case $e instanceof EmailAlreadyInSystemException:
             return $this->renderException($e);
             break;
         case $e instanceof AlreadySyncedException:
             return $this->renderException($e);
             break;
         case $e instanceof CredentialsDoNotMatchException:
             return $this->renderException($e);
             break;
         default:
             return parent::render($request, $e);
     }
 }
开发者ID:vihugarcia,项目名称:vhglaraboot,代码行数:41,代码来源:Handler.php

示例4: render

 /**
  * 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 instanceof NotFoundHttpException) {
         return redirect(route('dashboard'));
     }
     return parent::render($request, $e);
 }
开发者ID:wyrover,项目名称:backendl5,代码行数:14,代码来源:Handler.php

示例5: render

 /**
  * 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);
     }
     if (config('app.debug')) {
         return parent::render($request, $e);
     }
     if ($e instanceof TokenMismatchException) {
         return redirect()->back()->withInput($request->except('_token'))->withErrors('A sua sessão expirou. Tente novamente.');
     }
     if (!$this->isHttpException($e)) {
         $pathInfo = $request->getPathInfo();
         $url = $request->url();
         $method = $request->method();
         $message = $e->getMessage() ?: get_class($e);
         $data = ['pathInfo' => $pathInfo, 'url' => $url, 'method' => $method, 'exception' => $message, 'input' => $request->all()];
         \Mail::send('emails.notify-webmaster', $data, function ($message) use($url) {
             $message->from('no-reply@andremiguelaa.com');
             $message->to('andremiguelaa@gmail.com', 'André Ascensão');
             $message->subject("Exception at {$url}");
         });
     }
     return parent::render($request, $e);
 }
开发者ID:andremiguelaa,项目名称:quiz-cascata,代码行数:32,代码来源:Handler.php

示例6: render

 /**
  * 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)
 {
     // LM: 09-02-2015
     // See: http://stackoverflow.com/questions/29115184/laravel-catch-tokenmismatchexception
     if ($e instanceof \Illuminate\Session\TokenMismatchException) {
         // If the erros is a token mismatch
         xplog('A token mismatch error happend', __METHOD__);
         /* @BOOKMARK: TODO For now just log the user out when a token mismatch happens */
         return redirect(route('logout'));
     }
     // See: https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5
     if ($this->isHttpException($e)) {
         // See: https://laracasts.com/discuss/channels/requests/laravel-5-404-page-driving-me-crazy
         switch ($e->getStatusCode()) {
             case '404':
                 return \Response::view('errors.custom.404');
                 break;
                 /*  case '500':
                         return \Response::view('errors.custom.500');   
                     break; */
             /*  case '500':
                     return \Response::view('errors.custom.500');   
                 break; */
             default:
                 return $this->renderHttpException($e);
                 break;
         }
     }
     if (config('app.debug')) {
         return $this->renderExceptionWithWhoops($e);
     }
     return parent::render($request, $e);
 }
开发者ID:rafaelgandi,项目名称:wasabi_artisan,代码行数:40,代码来源:Handler.php

示例7: render

 /**
  * 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 (App::environment() == 'local') {
         return parent::render($request, $e);
     }
     return response()->json(['error' => ['message' => $e->getMessage()]]);
 }
开发者ID:Temoto-kun,项目名称:juan-n-juan,代码行数:14,代码来源:Handler.php

示例8: render

 /**
  * 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', [], 404);
     }
     return parent::render($request, $e);
 }
开发者ID:minhajCSE,项目名称:teleaus-dev,代码行数:14,代码来源:Handler.php

示例9: render

 /**
  * 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 ModelAlreadyExistsException) {
         return redirect()->back()->withErrors([$e->getMessage()]);
     }
     return parent::render($request, $e);
 }
开发者ID:yassinbarrani,项目名称:ThermoPiWebUI,代码行数:14,代码来源:Handler.php

示例10: render

 /**
  * 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 ($exception instanceof ValidationException && $this->isApiRoute($request)) {
         return response()->error($exception->validator, 422);
     }
     return parent::render($request, $exception);
 }
开发者ID:jadjoubran,项目名称:laravel5-angular-material-starter,代码行数:14,代码来源:Handler.php

示例11: render

 /**
  * 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);
     /* COMMENT ABOVE AND UNCOMMENT BELOW TO REDIRECT FOR CUSTOM ERROR HANDLING */
     /* if ($this->isHttpException($e)) {
                 switch ($e->getStatusCode()) {
                     // not found
                     case 404:
                         die("404 Redirect to Page not found here in app/Exceptions/Handler.php");
                         return redirect()->guest('home');
                         break;
     
                     // internal error
                     case '500':
                         die("500 Redirect to internal error page here in app/Exceptions/Handler.php");
                         return redirect()->guest('home');
                         break;
     
                     default:
                         return $this->renderHttpException($e);
                         break;
                 }
             } else {
                 return parent::render($request, $e);
             } */
 }
开发者ID:DinanathThakur,项目名称:Flash-Sale-Ecommerce-Portal-PHP,代码行数:36,代码来源:Handler.php

示例12: render

 /**
  * 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)
 {
     //There should really be a better way to get this into json,
     //but this works as well
     if ($e instanceof ValidationException) {
         $message = "[";
         $doneOne = false;
         foreach ($e->validator->messages()->all() as $err) {
             if (!$doneOne) {
                 $doneOne = true;
             } else {
                 $message = $message . ",";
             }
             $message = $message . $err . "\n";
         }
         $message = $message . "]";
         return response($message, 400)->header("Content-Type", "application/json");
     } else {
         if ($e instanceof HttpException) {
             if ($e->getStatusCode() == 404) {
                 return response(File::get(public_path() . '/index.html'));
             }
             return $this->renderHttpException($e);
         }
     }
     return parent::render($request, $e);
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:34,代码来源:Handler.php

示例13: render

 /**
  * 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 ($request->is('webhook/*')) {
         return $this->getJsonResponseForException($request, $e);
     }
     return parent::render($request, $e);
 }
开发者ID:ngmy,项目名称:webloyer,代码行数:14,代码来源:Handler.php

示例14: render

 /**
  * 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 (in_array(get_class($e), $this->dontReport)) {
         return parent::render($request, $e);
     }
     return response()->view('errors.500', [], 500);
 }
开发者ID:chrisforrence,项目名称:voxcom-solutions,代码行数:14,代码来源:Handler.php

示例15: render

 /**
  * 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 redirect()->route('home');
       }*/
     return parent::render($request, $e);
 }
开发者ID:MehmetNuri,项目名称:Blog,代码行数:14,代码来源:Handler.php


注:本文中的Illuminate\Foundation\Exceptions\Handler::render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。