作者:GreenHacker
项目:geo-endpoin
/**
* 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);
}
作者:jshaye
项目:hookbo
/**
* 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);
}
作者:cosey
项目:lume
/**
* 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);
}
作者:jrento
项目:volumi
/**
* 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);
}
作者:nerdif
项目:Saldo-TUC-AP
/**
* 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);
}
作者:edcorewe
项目:domino
/**
* 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);
}
作者:shaunpersa
项目:reflect-ap
/**
* 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);
}
作者:ssddanbrow
项目:BookStack-Sit
/**
* 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);
}
作者:penoona
项目:giving-circl
/**
* 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);
}
作者:rajabishe
项目:begi
/**
* 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);
}
作者:thebhandariprakas
项目:LumenAuthenticatio
/**
* 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);
}
作者:ellipsesynergi
项目:backend-skeleto
/**
* 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);
}
作者:MikeMcMulla
项目:simple-url-shortene
/**
* 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);
}
作者:Ognestra
项目:lumen-admi
/**
* 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);
}
作者:Munk9
项目:Hovedopgav
/**
* 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);
}
作者:spir
项目:api-cor
/**
* 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;
}
作者:avverti
项目:pronto-cm
/**
* 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);
}
作者:krossroa
项目:doc-comparato
/**
* 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);
}
作者:chatbox-in
项目:lumen-provider
/**
* @return mixed
*/
public function getReporter() : callable
{
$default = function (Exception $e) {
parent::report($e);
};
return $this->reporter ?: $default;
}
作者:Evy
项目:cffs-ap
/**
* 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);
}