ExceptionHandler { protected function prepareResponse($request, Exception $e) { return $this->toIlluminateResponse( $this->customRenderHttpException($request, $e), $e ); } private function customRenderHttpException(Request $request, HttpException $e) { $status = $e->getStatusCode(); $paths = collect(config('view.paths')); view()->replaceNamespace('errors', $paths->map(function ($path) use ($request) { if ($request->is('admin/*')) { return "{$path}/admin/errors"; } return "{$path}/service/errors"; })->push(__DIR__ . '/views')->all());
if (view()->exists($view = "errors::{$status}")) { return response()->view($view, ['exception' => $e], $status, $e->getHeaders()); } return $this->convertExceptionToResponse($e); }