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


PHP NotFoundHttpException::getMessage方法代码示例

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


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

示例1: render

 /**
  * Render an exception into an HTTP response.
  * 该方法响应异常信息到客户端 : 该方法返回的数据必须是一个response对象
  * 异常的处理是在请求结束前处理,因此这里的render 方法直接设定为返回异常信息给响应。
  * @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);
     }
     $msg = $e->getmessage();
     if ($e instanceof InvalidArgumentException) {
         return response()->json(['data' => $msg, 'state' => '901', 'timeStamp' => time()]);
     }
     if ($e instanceof UnexpectedValueException) {
         return response()->json(['data' => $msg, 'state' => '902', 'timeStamp' => time()]);
     }
     if ($e instanceof SignatureInvalidException) {
         return response()->json(['data' => $msg, 'state' => '903', 'timeStamp' => time()]);
         // return response()->view('welcome', [], 503);
         // return  response("ddddd")->header("x-at",'xxx');
     }
     if ($e instanceof BeforeValidException) {
         return response()->json(['data' => $msg, 'state' => '904', 'timeStamp' => time()]);
     }
     if ($e instanceof ExpiredException) {
         return response()->json(['data' => $msg, 'state' => '905', 'timeStamp' => time()]);
     }
     if ($e instanceof CustomException) {
         return response()->json(['data' => $msg, 'state' => '1005', 'timeStamp' => time()]);
     }
     return parent::render($request, $e);
 }
开发者ID:xzungshao,项目名称:lar5-one,代码行数:36,代码来源: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)
 {
     \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

示例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);
     } else {
         if ($request->wantsJson()) {
             // Define the response
             $response = ['errors' => 'Sorry, something went wrong.', 'message' => $e->getMessage()];
             // 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['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();
             }
             \Log::error($e);
             // Return a JSON response with the response array and status code
             return response()->json($response, $status);
         }
     }
     return parent::render($request, $e);
 }
开发者ID:hcvst,项目名称:telegramlogin,代码行数:36,代码来源: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);
     }
     /**
      * 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

示例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);
     } 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

示例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)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     } elseif ($e instanceof OAuthException) {
         $response = response()->json(['error' => $e->errorType, 'error_description' => $e->getMessage()], $e->httpStatusCode, $e->getHttpHeaders());
         return $this->corsService->addActualRequestHeaders($response, $request);
     }
     return parent::render($request, $e);
 }
开发者ID:davidpetro88,项目名称:laravel-codedelivery,代码行数:17,代码来源: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)
 {
     $status = 500;
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
         $status = 404;
     }
     return response()->json(["error" => $e->getMessage()], $status);
     //        return parent::render($request, $e);
 }
开发者ID:akstorm,项目名称:test-parser-php,代码行数:17,代码来源: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 ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     } elseif ($e instanceof HttpException && \App::isLocal() === false) {
         Response::json(['result' => false, 'message' => $e->getMessage()])->setStatusCode($e->getStatusCode())->send();
         exit;
     }
     return parent::render($request, $e);
 }
开发者ID:realshadow,项目名称:satis-control-panel,代码行数:17,代码来源: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 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

示例10: 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()) {
         return Response::json(['code' => '', 'message' => $e->getMessage(), 'debugMessage' => $e->getTraceAsString()], 500);
     } else {
         return parent::render($request, $e);
     }
 }
开发者ID:valleyblvd,项目名称:YueFang-ops-web,代码行数:18,代码来源: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);
     }
     // add handler for Ajax requests
     if ($request->isXmlHttpRequest()) {
         return Response::json(['status' => '500', 'message' => $e->getMessage()], 500);
     }
     return parent::render($request, $e);
 }
开发者ID:kcardina,项目名称:bmooc-laravel,代码行数:18,代码来源: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)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     // don't display SOAP Error
     if (str_contains($e->getMessage(), 'SOAP-ERROR')) {
         return;
     }
     return parent::render($request, $e);
 }
开发者ID:ptournem,项目名称:AXIS_MoM_WebSite,代码行数:18,代码来源: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 ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     $message = !empty($e->getMessage()) ? $e->getMessage() : "Error";
     //        return view('errors.500')->with(compact('request', 'e', 'message'));
     return response()->view('errors.500', compact('request', 'e', 'message'), 500);
     //        return response()->view('errors.500', compact('request', 'e'), 500);
     //        return view('errors.500')->with(compact('request', 'e'));
     //        return parent::render($request, $e);
 }
开发者ID:Ravaelles,项目名称:Elder,代码行数:19,代码来源: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 ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     if ($e instanceof OAuthException) {
         return \ResponseFractal::setStatusCode($e->httpStatusCode)->respondCustomError($e->getMessage(), $e->errorType, [$e->parameter]);
     }
     if (config('app.debug')) {
         return $this->renderExceptionWithWhoops($e);
     }
     return parent::render($request, $e);
 }
开发者ID:gdgfoz,项目名称:codelab-todo-api,代码行数:20,代码来源: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 ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     if ($e instanceof NotFoundHttpException) {
         return response()->view('errors.404', [], 404);
     }
     //As to preserve the catch all
     if ($e instanceof GeneralException) {
         return redirect()->back()->withInput()->withFlashDanger($e->getMessage());
     }
     return parent::render($request, $e);
 }
开发者ID:yewei-cao,项目名称:noodle,代码行数:21,代码来源:Handler.php


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