Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Promise.php

function Promise::handleException

Converts a Guzzle exception into an Httplug exception.

Return value

HttplugException

1 call to Promise::handleException()
Promise::__construct in vendor/php-http/guzzle7-adapter/src/Promise.php

File

vendor/php-http/guzzle7-adapter/src/Promise.php, line 101

Class

Promise
Wrapper around Guzzle promises.

Namespace

Http\Adapter\Guzzle7

Code

private function handleException(GuzzleExceptions\GuzzleException $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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal