protected function handleError(BadResponseException $e)
    {
        $request = $e->getRequest();
        $response = $e->getResponse();

        $level = floor($response->getStatusCode() / 100);

        if ($level == '4') {
            $label = 'Client error response';
        } elseif ($level == '5') {
            $label = 'Server error response';
        } else {
            $label = 'Unsuccessful response';
        }

        $message = $label .
            "\n [url] " . $request->getUri() .
            "\n [status code] " . $response->getStatusCode() .
            "\n [message] ";

        $body = $response->getBody();
        $json = json_decode($body, true);
        $message .= ($json != null && array_key_exists('message', $json)) ? $json['message'] : $body;

        if ($level == '4' && strpos($message, 'page with this title already exists') !== false) {
            return new DuplicateTitleException($message, 0, $e->getPrevious());
        }

        return new BadResponseException($message, $request, $response, $e->getPrevious());
    }
protected function handleError(BadResponseException $e)
    {
        $request = $e->getRequest();
        $response = $e->getResponse();

        $level = floor($response->getStatusCode() / 100);

        if ($level == '4') {
            $label = 'Client error response';
        } elseif ($level == '5') {
            $label = 'Server error response';
        } else {
            $label = 'Unsuccessful response';
        }

        $message = $label .
            "\n [url] " . $request->getUri() .
            "\n [status code] " . $response->getStatusCode() .
            "\n [message] ";

        $body = $response->getBody();
        $json = json_decode($body, true);
        $message .= ($json != null && array_key_exists('message', $json)) ? $json['message'] : $body;

        if ($level == '4' && strpos($message, 'page with this title already exists') !== false) {
            return new DuplicateTitleException($message, 0, $e->getPrevious());
        }

        return new BadResponseException($message, $request, $response, $e->getPrevious());
    }
protected function handleError ( BadResponseException $ e ) { $ request = $ e -> getRequest ( ) ; $ response = $ e -> getResponse ( ) ; $ level = floor ( $ response -> getStatusCode ( ) / 100 ) ; if ( $ level == '4' ) { $ label = 'Client error response' ; } elseif ( $ level == '5' ) { $ label = 'Server error response' ; } else { $ label = 'Unsuccessful response' ; } $ message = $ label . "\n [url] " . $ request -> getUri ( ) . "\n [status code] " . $ response -> getStatusCode ( ) . "\n [message] " ; $ body = $ response -> getBody ( ) ; $ json = json_decode ( $ body , true ) ; $ message .= ( $ json != null && array_key_exists ( 'message' , $ json ) ) ? $ json [ 'message' ] : $ body ; if ( $ level == '4' && strpos ( $ message , 'page with this title already exists' ) !== false ) { return new DuplicateTitleException ( $ message , 0 , $ e -> getPrevious ( ) ) ; } return new BadResponseException ( $ message , $ request , $ response , $ e -> getPrevious ( ) ) ; }
The standard error message from guzzle is quite poor in informations,
this will give little bit more sense to it and return it

@param BadResponseException $e
@return \Exception
The standard error message from guzzle is quite poor in informations this will give little bit more sense to it and return it