make(ExceptionHandler::class); } catch (Throwable) { return array_merge($this->getExceptionContext($e, $depth), $response); } if ((! method_exists($handler, 'isReporting')) || ! $handler->isReporting($e)) { if (method_exists($handler, 'buildContextForException') && is_array($normalizedHandlerExceptionContext = $this->normalize($handler->buildContextForException($e), $depth + 1)) ) { $response = array_merge( $normalizedHandlerExceptionContext, $response ); } elseif (method_exists($e, 'context')) { $response = array_merge($this->getExceptionContext($e, $depth), $response); } } return $response; } /** * Extract the context from the exception if available. * * @return array */ protected function getExceptionContext(Throwable $e, int $depth): array { if (! method_exists($e, 'context')) { return []; } try { $exceptionContext = $this->normalize($e->context(), $depth + 1); } catch (Throwable) { return []; } return is_array($exceptionContext) ? $exceptionContext : []; } }