reportable(function (\BadMethodCallException $e) { return app()->environment() !== 'production'; }); $this->reportable(function (ConnectionException $e) { return app()->environment() !== 'production'; }); } /** * Render an exception into an HTTP response. * * @param Request $request * @param \Exception $exception * @return Response */ public function render($request, Throwable $exception) { if ($request->wantsJson()) { if ($exception instanceof HttpResponseException) { return $exception->getResponse(); } if ($exception instanceof ValidationException) { return response()->json([ 'message' => $exception->getMessage(), 'errors' => $exception->validator->getMessageBag(), ], $exception->status); } $isHttp = $this->isHttpException($exception); return response()->json( ['error' => $exception->getMessage()], $isHttp ? $exception->getStatusCode() : 500, $isHttp ? $exception->getHeaders() : [], ); } return parent::render($request, $exception); } }