protected function exception($response, $header) {
        $message = '[HTTP ' . $response->getStatusCode() . '] ' . $header;

        $content = $response->getContent();
        if (is_array($content)) {
            $message .= isset($content['message']) ? ': ' . $content['message'] : '';
            $code = isset($content['code']) ? $content['code'] : $response->getStatusCode();
            return new RestException($message, $code, $response->getStatusCode());
        } else {
            return new RestException($message, $response->getStatusCode(), $response->getStatusCode());
        }
    }
protected function exception($response, $header) {
        $message = '[HTTP ' . $response->getStatusCode() . '] ' . $header;

        $content = $response->getContent();
        if (is_array($content)) {
            $message .= isset($content['message']) ? ': ' . $content['message'] : '';
            $code = isset($content['code']) ? $content['code'] : $response->getStatusCode();
            return new RestException($message, $code, $response->getStatusCode());
        } else {
            return new RestException($message, $response->getStatusCode(), $response->getStatusCode());
        }
    }
protected function exception ( $ response , $ header ) { $ message = '[HTTP ' . $ response -> getStatusCode ( ) . '] ' . $ header ; $ content = $ response -> getContent ( ) ; if ( is_array ( $ content ) ) { $ message .= isset ( $ content [ 'message' ] ) ? ': ' . $ content [ 'message' ] : '' ; $ code = isset ( $ content [ 'code' ] ) ? $ content [ 'code' ] : $ response -> getStatusCode ( ) ; return new RestException ( $ message , $ code , $ response -> getStatusCode ( ) ) ; } else { return new RestException ( $ message , $ response -> getStatusCode ( ) , $ response -> getStatusCode ( ) ) ; } }
Create the best possible exception for the response.

Attempts to parse the response for Twilio Standard error messages and use
those to populate the exception, falls back to generic error message and
HTTP status code.

@param Response $response Error response
@param string $header Header for exception message
@return TwilioException
Create the best possible exception for the response .