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


PHP NotFoundHttpException::getCode方法代码示例

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


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

示例1: 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)
 {
     \App\Http\Controllers\BaseController::setHeader();
     /**
      * Handle Service Exceptions
      */
     if ($e instanceof \App\Exceptions\ServiceException) {
         $response = array('status' => $e->getCode(), 'message' => $e->getMessage());
         ServiceLog::requestLog($request, $response);
         return \Response::json($response);
     }
     if (!\Config::get('app.debug')) {
         if ($e instanceof ModelNotFoundException) {
             $e = new NotFoundHttpException($e->getMessage(), $e);
         }
         if ($e instanceof \Illuminate\Contracts\Container\BindingResolutionException) {
             $response = array('status' => 604, 'message' => '相应服务没有启动');
         } elseif ($e instanceof \Symfony\Component\Debug\Exception\FatalErrorException) {
             $response = array('status' => 605, 'message' => 'method wrong');
         } else {
             $response = array('status' => $e->getCode() ?: 606, 'message' => $e->getMessage() ?: '请检查请求数据');
         }
         ServiceLog::errorLog($request, $response);
         return \Response::json($response);
     }
     return parent::render($request, $e);
 }
开发者ID:icevisual,项目名称:transfer,代码行数:34,代码来源: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)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     /**
      * Response Exception as Json
      *
      */
     if ($request->wantsJson()) {
         $error = new \stdclass();
         $error->error = true;
         if ($e instanceof NotFoundHttpException) {
             $error->code = $e->getStatusCode();
         } else {
             $error->code = $e->getCode();
         }
         if ($error->code == 0) {
             $error->code = 400;
         }
         if ($e instanceof ValidatorException) {
             $error->message = $e->getMessageBag();
         } else {
             $error->message = $e->getMessage();
             if (\App::environment('local')) {
                 $error->file = $e->getFile();
                 $error->line = $e->getLine();
             }
         }
         return response()->json($error, $error->code);
     }
     return parent::render($request, $e);
 }
开发者ID:adrianodrix,项目名称:codedelivery.dev,代码行数:40,代码来源:Handler.php

示例3: 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);
     } elseif ($e instanceof ApiException) {
         return response()->json(['error' => true, 'message_info' => $e->getMessage()], $e->getCode());
     }
     return parent::render($request, $e);
 }
开发者ID:jamesddube,项目名称:mps-server,代码行数:16,代码来源: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 = new NotFoundHttpException($e->getMessage(), $e);
     }
     if ($request->ajax() || $request->wantsJson()) {
         $json = ['success' => false, 'error' => ['code' => $e->getCode(), 'message' => $e->getMessage()]];
         return response()->json($json, 400);
     }
     return parent::render($request, $e);
 }
开发者ID:DCgov,项目名称:dc-madison,代码行数:18,代码来源: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 ($e instanceof HttpException) {
         $errorData = ["message" => $e->getMessage(), "httpCode" => $e->getStatusCode(), "code" => $e->getCode()];
         if ($request->ajax()) {
             return response()->json($errorData, $errorData['httpCode']);
         } else {
             return response()->view('errors.phylab', $errorData, $errorData['httpCode']);
         }
     }
     return parent::render($request, $e);
 }
开发者ID:kibbon,项目名称:Phylab-Web,代码行数:22,代码来源:Handler.php


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