當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Exceptions\Handler類代碼示例

本文整理匯總了PHP中Laravel\Lumen\Exceptions\Handler的典型用法代碼示例。如果您正苦於以下問題:PHP Handler類的具體用法?PHP Handler怎麽用?PHP Handler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Handler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
 {
     if ($e instanceof ModelNotFoundException) {
         return response()->json(['error' => ['message' => 'Resource Not Found!', 'code' => 404]], 404);
     }
     return parent::render($request, $e);
 }
開發者ID:GreenHackers,項目名稱:geo-endpoint,代碼行數:14,代碼來源: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 HookBotException) {
         return response()->json($e->getPayload(), $e->getErrorCode());
     }
     return parent::render($request, $e);
 }
開發者ID:jshayes,項目名稱:hookbot,代碼行數:14,代碼來源: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 (!env('APP_DEBUG') and $this->isHttpException($e)) {
         return $this->renderHttpException($e);
     }
     return parent::render($request, $e);
 }
開發者ID:coseyo,項目名稱:lumen,代碼行數:14,代碼來源: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 \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
         return view('home');
     }
     return parent::render($request, $e);
 }
開發者ID:jrenton,項目名稱:volumio,代碼行數: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 NotFoundHttpException || $e instanceof ModelNotFoundException || $e instanceof MethodNotAllowedHttpException) {
         return response()->json(['error' => ['message' => 'Not found', 'status_code' => 404]], 404);
     }
     return parent::render($request, $e);
 }
開發者ID:nerdify,項目名稱:Saldo-TUC-API,代碼行數:15,代碼來源: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) {
         return response()->json('Not found.', 404);
     }
     return parent::render($request, $e);
 }
開發者ID:edcoreweb,項目名稱:dominox,代碼行數:14,代碼來源: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 ($e instanceof AbstractAppException) {
         return $e->response($request);
     }
     return parent::render($request, $e);
 }
開發者ID:shaunpersad,項目名稱:reflect-api,代碼行數: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 HttpException) {
         return view('errors/404');
     }
     return parent::render($request, $e);
 }
開發者ID:ssddanbrown,項目名稱:BookStack-Site,代碼行數: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 NotFoundHttpException) {
         return view('missing');
     }
     return parent::render($request, $e);
 }
開發者ID:penoonan,項目名稱:giving-circle,代碼行數:14,代碼來源: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 BadRequestHttpException) {
         return response()->json(['success' => false, 'errors' => ['Please provide a token']], 400);
     }
     return parent::render($request, $e);
 }
開發者ID:rajabishek,項目名稱:begin,代碼行數: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 TokenMismatchException) {
         return view('error.error');
     }
     return parent::render($request, $e);
 }
開發者ID:thebhandariprakash,項目名稱:LumenAuthentication,代碼行數:14,代碼來源: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)
 {
     $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);
 }
開發者ID:ellipsesynergie,項目名稱:backend-skeleton,代碼行數:41,代碼來源: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 instanceof NotFoundHttpException) {
         return view('errors.404');
     }
     return parent::render($request, $e);
 }
開發者ID:MikeMcMullan,項目名稱:simple-url-shortener,代碼行數: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 ($e instanceof ModelNotFoundException) {
         return new Response(view('admin::errors.404'), 404);
     }
     return parent::render($request, $e);
 }
開發者ID:Ognestraz,項目名稱:lumen-admin,代碼行數: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('/#/' . $request->path());
     }
     return parent::render($request, $e);
 }
開發者ID:Munk91,項目名稱:Hovedopgave,代碼行數:14,代碼來源:Handler.php


注:本文中的Laravel\Lumen\Exceptions\Handler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。