protected function getResponseError(WebResponse $response)
    {
        $error = [
            "message" => "",
            "code"    => 0
        ];
        
        $response_text = $response->getBody();
        $obj = json_decode($response_text, true);
        if (!$obj) {
            if (stripos($response_text, "<H1>401 Unauthorized.</H1>") !== false) {
                $error["message"] = "Unauthorized";
                $error["code"]    = RPCErrorCodes::WALLET_PASSPHRASE_INCORRECT;
            } else if (strpos($response_text, "<?xml") !== false) {
                $xml = simplexml_load_string($response_text);
                if ($xml && isset($xml->body->p[0])) {
                    $error["message"] = trim((string)$xml->body->p[0]);
                    $error["message"] = preg_replace("/[\\n\\r]/", "", $error["message"]);
                    $error["message"] = preg_replace("/\\s{2,}/", " ", $error["message"]);
                    $error["code"]    = $response->getCode();
                } else {
                    $error["message"] = $response_text;
                    $error["code"]    = $response->getCode();
                }
            }
        } else if (!empty($obj["error"])) {
            $error = $obj["error"];
        }
        
        return $error;
    }