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;
    }