本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}