Exemplo n.º 1
0
 /**
  * Converts a Guzzle exception into an Httplug exception.
  *
  * @param GuzzleExceptions\GuzzleException $exception
  * @param RequestInterface                 $request
  *
  * @return HttplugException
  */
 private function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request)
 {
     if ($exception instanceof GuzzleExceptions\SeekException) {
         return new HttplugException\RequestException($exception->getMessage(), $request, $exception);
     }
     if ($exception instanceof GuzzleExceptions\ConnectException) {
         return new HttplugException\NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
     }
     if ($exception instanceof GuzzleExceptions\RequestException) {
         // Make sure we have a response for the HttpException
         if ($exception->hasResponse()) {
             return new HttplugException\HttpException($exception->getMessage(), $exception->getRequest(), $exception->getResponse(), $exception);
         }
         return new HttplugException\RequestException($exception->getMessage(), $exception->getRequest(), $exception);
     }
     return new HttplugException\TransferException($exception->getMessage(), 0, $exception);
 }
Exemplo n.º 2
0
 /**
  * Converts a Guzzle exception into a Novuso exception
  *
  * @param GuzzleExceptions\GuzzleException $exception The exception
  * @param RequestInterface                 $request   The request
  *
  * @return NovusoExceptions\Exception
  */
 protected function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request)
 {
     if ($exception instanceof GuzzleExceptions\SeekException) {
         return new NovusoExceptions\RequestException($exception->getMessage(), $request, $exception);
     }
     if ($exception instanceof GuzzleExceptions\ConnectException) {
         return new NovusoExceptions\NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
     }
     if ($exception instanceof GuzzleExceptions\RequestException) {
         if ($exception->hasResponse()) {
             return new NovusoExceptions\HttpException($exception->getMessage(), $exception->getRequest(), $exception->getResponse(), $exception);
         }
         return new NovusoExceptions\RequestException($exception->getMessage(), $exception->getRequest(), $exception);
     }
     return new NovusoExceptions\TransferException($exception->getMessage(), 0, $exception);
 }