ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } } ponse * @param \Throwable $e * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ protected function toIlluminateResponse($response, Throwable $e) { if ($response instanceof SymfonyRedirectResponse) { $response = new RedirectResponse( $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all() ); } else { $response = response( $response->getContent(), $response->getStatusCode(), $response->headers->all() ); } return $response->withException($e); } /** * Prepare a JSON response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Illuminate\Http\JsonResponse */ protected function prepareJsonResponse($request, Throwable $e) { return response()->json( $this->convertExceptionToArray($e), $this->isHttpException($e) ? $e->getStatusCode() : 500, $this->isHttpException($e) ? $e->getHeaders() : [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } /** * Convert the given exception to an array. * * @param \Throwable $e * @return array */ protected function convertExceptionToArray(Throwable $e) { return config('app.debug') ? [ 'message' => $e->getMessage(), 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => (new Collection($e->getTrace()))->map(fn ($trace) => Arr::except($trace, ['args']))->all(), ] : [ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error', ]; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void * * @internal This method is not meant to be used or overwritten outside the framework. */ public function renderForConsole($output, Throwable $e) { if ($e instanceof CommandNotFoundException) { $message = Str::of($e->getMessage())->explode('.')->first(); if (! empty($alternatives = $e->getAlternatives())) { $message .= '. Did you mean one of these?'; (new Error($output))->render($message); (new BulletList($output))->render($alternatives); $output->writeln(''); } else { (new Error($output))->render($message); } return; } (new ConsoleApplication)->renderThrowable($e, $output); } /** * Do not report duplicate exceptions. * * @return $this */ public function dontReportDuplicates() { $this->withoutDuplicates = true; return $this; } /** * Determine if the given exception is an HTTP exception. * * @param \Throwable $e * @return bool */ protected function isHttpException(Throwable $e) { return $e instanceof HttpExceptionInterface; } /** * Map the exception to a log level. * * @param \Throwable $e * @return \Psr\Log\LogLevel::* */ protected function mapLogLevel(Throwable $e) { return Arr::first( $this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR ); } /** * Create a new logger instance. * * @return \Psr\Log\LoggerInterface */ protected function newLogger() { return $this->container->make(LoggerInterface::class); } }