本文整理汇总了PHP中Laravel\Lumen\Exceptions\Handler类的典型用法代码示例。如果您正苦于以下问题:PHP Handler类的具体用法?PHP Handler怎么用?PHP Handler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Handler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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)
{
$debug = env('APP_DEBUG', false);
$message = $e->getMessage();
if (!$message) {
$message = 'An error occurred';
}
$debugData = ['exception' => get_class($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => explode("\n", $e->getTraceAsString())];
$responseData = ['message' => $message];
if ($e instanceof HttpExceptionInterface) {
if (method_exists($e, 'getResponse')) {
if ($e instanceof TransformableInterface) {
$responseData = $e->transform(app(ValidationExceptionTransformer::class));
} else {
$responseData = $e->getResponse();
}
}
}
if ($debug) {
$responseData['debug'] = $debugData;
}
$response = parent::render($request, $e);
$response = new JsonResponse($responseData, $response->getStatusCode(), $response->headers->all(), JSON_PRETTY_PRINT);
$response->exception = $e;
app('Asm89\\Stack\\CorsService')->addActualRequestHeaders($response, $request);
return $response;
}
开发者ID:spira,项目名称:api-core,代码行数:35,代码来源:Handler.php
示例17: 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 PageNotFoundException) {
return response()->make($e->getMessage(), 404);
}
return parent::render($request, $e);
}
开发者ID:avvertix,项目名称:pronto-cms,代码行数:14,代码来源:Handler.php
示例18: 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 DocumentNotFoundException) {
return view('error')->with('errorMessage', $e->getMessage());
}
return parent::render($request, $e);
}
开发者ID:krossroad,项目名称:doc-comparator,代码行数:14,代码来源:Handler.php
示例19: getReporter
/**
* @return mixed
*/
public function getReporter() : callable
{
$default = function (Exception $e) {
parent::report($e);
};
return $this->reporter ?: $default;
}
开发者ID:chatbox-inc,项目名称:lumen-providers,代码行数:10,代码来源:Handler.php
示例20: render
/**
* Render an exception into an HTTP response
*
* @param Request $request
* @param Exception $e
* @return Response
*/
public function render($request, Exception $e)
{
if (config('app.debug')) {
return parent::render($request, $e);
}
return $this->handle($request, $e);
}
开发者ID:Evyy,项目名称:cffs-api,代码行数:14,代码来源:Handler.php
注:本文中的Laravel\Lumen\Exceptions\Handler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论