diff --git a/kraken.js b/kraken.js index 4cedb7f..7685156 100644 --- a/kraken.js +++ b/kraken.js @@ -43,15 +43,20 @@ const rawRequest = async (url, headers, data, timeout) => { const response = JSON.parse(body); if(response.error && response.error.length) { - const error = response.error - .filter((e) => e.startsWith('E')) + const error = response.error; + if(typeof error === 'object') { + error.filter((e) => e.startsWith('E')) .map((e) => e.substr(1)); - if(!error.length) { - throw new Error("Kraken API returned an unknown error"); - } + if(!error.length) { + throw new Error("Kraken API returned an unknown error"); + } - throw new Error(error.join(', ')); + throw new Error(error.join(', ')); + } + else { + throw new Error(error); + } } return response;