ConnectException example

 catch (\InvalidArgumentException $e) {
            throw $e;
        } catch (\Exception $e) {
            // Determine if the error was a networking error.             $message = $e->getMessage();
            // This list can probably get more comprehensive.             if (false !== \strpos($message, 'getaddrinfo') // DNS lookup failed                 || false !== \strpos($message, 'Connection refused')
                || false !== \strpos($message, "couldn't connect to host") // error on HHVM                 || false !== \strpos($message, 'connection attempt failed')
            ) {
                $e = new ConnectException($e->getMessage()$request$e);
            } else {
                $e = RequestException::wrapException($request$e);
            }
            $this->invokeStats($options$request$startTime, null, $e);

            return P\Create::rejectionFor($e);
        }
    }

    private function invokeStats(
        array $options,
        
$ctx['errno'],
            $ctx['error'],
            'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
        );
        $uriString = (string) $easy->request->getUri();
        if ($uriString !== '' && false === \strpos($ctx['error']$uriString)) {
            $message .= \sprintf(' for %s', $uriString);
        }

        // Create a connection exception if it was a specific error code.         $error = isset($connectionErrors[$easy->errno])
            ? new ConnectException($message$easy->request, null, $ctx)
            : new RequestException($message$easy->request, $easy->response, null, $ctx);

        return P\Create::rejectionFor($error);
    }

    /** * @return array<int|string, mixed> */
    private function getDefaultConf(EasyHandle $easy): array
    {
        $conf = [
            
Home | Imprint | This part of the site doesn't use cookies.