/** * Collects an exception. * * @param \Ivory\HttpAdapter\HttpAdapterInterface $httpAdapter The http adapter. * @param \Ivory\HttpAdapter\HttpAdapterException $exception The exception. */ private function collectException(HttpAdapterInterface $httpAdapter, HttpAdapterException $exception) { $this->getTimer()->stop($exception->getRequest()); $this->datas['exceptions'][] = array('adapter' => $httpAdapter->getName(), 'exception' => $this->getFormatter()->formatException($exception), 'request' => $this->getFormatter()->formatRequest($exception->getRequest()), 'response' => $exception->hasResponse() ? $this->getFormatter()->formatResponse($exception->getResponse()) : null); }
/** * Logs error. * * @param \Ivory\HttpAdapter\HttpAdapterInterface $httpAdapter The http adapter. * @param \Ivory\HttpAdapter\HttpAdapterException $exception The exception. * * @return \Ivory\HttpAdapter\Message\InternalRequestInterface The logged request. */ private function error(HttpAdapterInterface $httpAdapter, HttpAdapterException $exception) { $request = $this->getTimer()->stop($exception->getRequest()); $this->logger->error(sprintf('Unable to send "%s %s".', $exception->getRequest()->getMethod(), (string) $exception->getRequest()->getUri()), array('adapter' => $httpAdapter->getName(), 'exception' => $this->getFormatter()->formatException($exception), 'request' => $this->getFormatter()->formatRequest($request), 'response' => $exception->hasResponse() ? $this->getFormatter()->formatResponse($exception->getResponse()) : null)); return $request; }
/** * Gets an array from an HttpAdapterException. * * @param HttpAdapterException $exception * * @return array */ public function exceptionToArray(HttpAdapterException $exception) { $array = ['code' => $exception->getCode(), 'message' => $exception->getMessage()]; if ($exception->hasRequest()) { $array['request'] = $this->internalRequestToArray($exception->getRequest()); } if ($exception->hasResponse()) { $array['response'] = $this->responseToArray($exception->getResponse()); } return $array; }