protected function processException(RequestException $exception): void
    {
        $requestContents = $this->getContentsFromMessage($exception->getRequest());
        $responseContents = $this->getContentsFromMessage($exception->getResponse());

        if ($exception instanceof ConnectException) {
            throw new ConnectionException($exception->getMessage(), $requestContents, $exception);
        } else {
            $message = $this->extractMessageFromErrorResponse($responseContents, $exception->getMessage());
            $statusCode = 0;
            if ($exception->getResponse() instanceof PsrResponseInterface) {
                $statusCode = $exception->getResponse()->getStatusCode();
            }

            throw $this->createApiClientException($statusCode, $message, $requestContents, $responseContents);
        }
    }