src/Guzzle/Http/Exception/BadResponseException.php
public static function factory(RequestInterface $request, Response $response)
    {
        if ($response->isClientError()) {
            $label = 'Client error response';
            $class = __NAMESPACE__ . '\\ClientErrorResponseException';
        } elseif ($response->isServerError()) {
            $label = 'Server error response';
            $class = __NAMESPACE__ . '\\ServerErrorResponseException';
        } else {
            $label = 'Unsuccessful response';
            $class = __CLASS__;
        }

        $message = $label . PHP_EOL . implode(PHP_EOL, array(
            '[status code] ' . $response->getStatusCode(),
            '[reason phrase] ' . $response->getReasonPhrase(),
            '[url] ' . $request->getUrl(),
        ));

        $e = new $class($message);
        $e->setResponse($response);
        $e->setRequest($request);

        return $e;
    }
public static function factory(RequestInterface $request, Response $response)
    {
        if ($response->isClientError()) {
            $label = 'Client error response';
            $class = __NAMESPACE__ . '\\ClientErrorResponseException';
        } elseif ($response->isServerError()) {
            $label = 'Server error response';
            $class = __NAMESPACE__ . '\\ServerErrorResponseException';
        } else {
            $label = 'Unsuccessful response';
            $class = __CLASS__;
        }

        $message = $label . PHP_EOL . implode(PHP_EOL, array(
            '[status code] ' . $response->getStatusCode(),
            '[reason phrase] ' . $response->getReasonPhrase(),
            '[url] ' . $request->getUrl(),
        ));

        $e = new $class($message);
        $e->setResponse($response);
        $e->setRequest($request);

        return $e;
    }
public static function factory ( RequestInterface $ request , Response $ response ) { if ( $ response -> isClientError ( ) ) { $ label = 'Client error response' ; $ class = __NAMESPACE__ . '\\ClientErrorResponseException' ; } elseif ( $ response -> isServerError ( ) ) { $ label = 'Server error response' ; $ class = __NAMESPACE__ . '\\ServerErrorResponseException' ; } else { $ label = 'Unsuccessful response' ; $ class = __CLASS__ ; } $ message = $ label . PHP_EOL . implode ( PHP_EOL , array ( '[status code] ' . $ response -> getStatusCode ( ) , '[reason phrase] ' . $ response -> getReasonPhrase ( ) , '[url] ' . $ request -> getUrl ( ) , ) ) ; $ e = new $ class ( $ message ) ; $ e -> setResponse ( $ response ) ; $ e -> setRequest ( $ request ) ; return $ e ; }
Factory method to create a new response exception based on the response code.

@param RequestInterface $request  Request
@param Response         $response Response received

@return BadResponseException
Factory method to create a new response exception based on the response code .