/** * {@inheritdoc} */ public function handle(Exception $exception) { if ($this->rethrow) { throw $exception; } foreach ($this->handlers as $index => $handler) { try { if (is_string($handler)) { $handler = $this->resolver->resolve($handler); $this->handlers->offsetSet($index, $handler); } else { if (is_array($handler) && is_string($handler[0])) { $handler[0] = $this->resolver->resolve($handler[0]); $this->handlers->offsetSet($index, $handler); } } if (!$this->matchesTypehint($handler, $exception)) { continue; } $result = $this->callHandler($handler, $exception); if ($result !== null) { return $this->makeResponse($result, $exception); } } catch (Exception $newException) { return $this->handle($newException); } } return $this->makeResponse($this->defaultHandler->handle($exception), $exception); }