src/Request.php
protected function checkResponseForErrors($response)
    {
        if (isset($response["error"])) {
            $msg = [];
            $parts = ["code", "description", "details"];
            
            foreach ($parts as $part) {
                if (!empty($response["error"][$part])) {
                    $msg[] = $part.": ".$response["error"][$part];
                }
            }

            $msg = implode(" | ", $msg);
            $code = $response["error"]["code"];

            if (!array_key_exists($code, $this->exceptions)) {
                $code = "default";
            }

            throw new $this->exceptions[$code]($msg);
        }

        return $response;
    }
protected function checkResponseForErrors($response)
    {
        if (isset($response["error"])) {
            $msg = [];
            $parts = ["code", "description", "details"];
            
            foreach ($parts as $part) {
                if (!empty($response["error"][$part])) {
                    $msg[] = $part.": ".$response["error"][$part];
                }
            }

            $msg = implode(" | ", $msg);
            $code = $response["error"]["code"];

            if (!array_key_exists($code, $this->exceptions)) {
                $code = "default";
            }

            throw new $this->exceptions[$code]($msg);
        }

        return $response;
    }
protected function checkResponseForErrors ( $ response ) { if ( isset ( $ response [ "error" ] ) ) { $ msg = [ ] ; $ parts = [ "code" , "description" , "details" ] ; foreach ( $ parts as $ part ) { if ( ! empty ( $ response [ "error" ] [ $ part ] ) ) { $ msg [ ] = $ part . ": " . $ response [ "error" ] [ $ part ] ; } } $ msg = implode ( " | " , $ msg ) ; $ code = $ response [ "error" ] [ "code" ] ; if ( ! array_key_exists ( $ code , $ this -> exceptions ) ) { $ code = "default" ; } throw new $ this -> exceptions [ $ code ] ( $ msg ) ; } return $ response ; }
Throws an Exception if the response contains an error
Throws an Exception if the response contains an error