/** * @param \Exception $e * @param RequestInterface|null $request * @return null|RequestResponse */ private function handleException(\Exception $e, RequestInterface $request = null) { $handlerResult = $this->runExceptionHandlers($e, $request); if (!$handlerResult) { $this->logger->error($e); } if ($request && !$request->getId()) { return null; } if ($handlerResult instanceof RequestResponse) { return $handlerResult; } return RequestResponse::constructExceptionErrorResponse($request ? $request->getId() : null, new InternalErrorException()); }