public function error()
    {

        $res = $this->response();

        if (!$res) {
            return null;
        }

        if ($this->ok()) {
            return null;
        }

        $message = ($res->getStatusCode() ? $res->getStatusCode() . ' ' : '') .
                   ($res->getReasonPhrase() ? $res->getReasonPhrase() : 'Unknown response reason phrase');

        try {

            $data = $this->json();

            if (!empty($data->message)) {
                $message = $data->message;
            }

            if (!empty($data->error_description)) {
                $message = $data->error_description;
            }

            if (!empty($data->description)) {
                $message = $data->description;
            }

        } catch (Exception $e) {
            // This should never happen
            $message .= ' (and additional error happened during JSON parse: ' . $e->getMessage() . ')';
        }

        return $message;

    }
public function error()
    {

        $res = $this->response();

        if (!$res) {
            return null;
        }

        if ($this->ok()) {
            return null;
        }

        $message = ($res->getStatusCode() ? $res->getStatusCode() . ' ' : '') .
                   ($res->getReasonPhrase() ? $res->getReasonPhrase() : 'Unknown response reason phrase');

        try {

            $data = $this->json();

            if (!empty($data->message)) {
                $message = $data->message;
            }

            if (!empty($data->error_description)) {
                $message = $data->error_description;
            }

            if (!empty($data->description)) {
                $message = $data->description;
            }

        } catch (Exception $e) {
            // This should never happen
            $message .= ' (and additional error happened during JSON parse: ' . $e->getMessage() . ')';
        }

        return $message;

    }
public function error ( ) { $ res = $ this -> response ( ) ; if ( ! $ res ) { return null ; } if ( $ this -> ok ( ) ) { return null ; } $ message = ( $ res -> getStatusCode ( ) ? $ res -> getStatusCode ( ) . ' ' : '' ) . ( $ res -> getReasonPhrase ( ) ? $ res -> getReasonPhrase ( ) : 'Unknown response reason phrase' ) ; try { $ data = $ this -> json ( ) ; if ( ! empty ( $ data -> message ) ) { $ message = $ data -> message ; } if ( ! empty ( $ data -> error_description ) ) { $ message = $ data -> error_description ; } if ( ! empty ( $ data -> description ) ) { $ message = $ data -> description ; } } catch ( Exception $ e ) { // This should never happen $ message .= ' (and additional error happened during JSON parse: ' . $ e -> getMessage ( ) . ')' ; } return $ message ; }
Returns a meaningful error message
@return string
Returns a meaningful error message