本文整理汇总了PHP中Laravel\Lumen\Exceptions\Handler::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Handler::render方法的具体用法?PHP Handler::render怎么用?PHP Handler::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Lumen\Exceptions\Handler
的用法示例。
在下文中一共展示了Handler::render方法的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);
}