diff --git a/src/api/coral.ts b/src/api/coral.ts index 2ef3e5e..5851bb6 100644 --- a/src/api/coral.ts +++ b/src/api/coral.ts @@ -56,6 +56,10 @@ export default class CoralApi { debug('fetch %s %s, response %s', method, url, response.status); + if (response.status !== 200) { + throw new ErrorResponse('[znc] Non-200 status code', response, await response.text()); + } + const data = await response.json() as CoralResponse; if (data.status === CoralStatus.TOKEN_EXPIRED && _autoRenewToken && !_attempt && this.onTokenExpired) { diff --git a/src/api/moon.ts b/src/api/moon.ts index 2395b07..615b938 100644 --- a/src/api/moon.ts +++ b/src/api/moon.ts @@ -49,6 +49,10 @@ export default class MoonApi { debug('fetch %s %s, response %s', method, url, response.status); + if (response.status !== 200) { + throw new ErrorResponse('[moon] Non-200 status code', response, await response.text()); + } + const data = await response.json() as T | MoonError; if ('errorCode' in data) { diff --git a/src/api/nooklink.ts b/src/api/nooklink.ts index c9cefa3..674f174 100644 --- a/src/api/nooklink.ts +++ b/src/api/nooklink.ts @@ -45,7 +45,7 @@ export default class NooklinkApi { debug('fetch %s %s, response %s', method, url, response.status); if (response.status !== 200 && response.status !== 201) { - throw new ErrorResponse('[nooklink] Unknown error', response, await response.text()); + throw new ErrorResponse('[nooklink] Non-200/201 status code', response, await response.text()); } const data = await response.json() as T | WebServiceError; diff --git a/src/api/splatnet2.ts b/src/api/splatnet2.ts index b016ad8..a7c1f97 100644 --- a/src/api/splatnet2.ts +++ b/src/api/splatnet2.ts @@ -53,7 +53,7 @@ export default class SplatNet2Api { debug('fetch %s %s, response %s', method, url, response.status); if (response.status !== 200) { - throw new ErrorResponse('[splatnet2] Unknown error', response, await response.text()); + throw new ErrorResponse('[splatnet2] Non-200 status code', response, await response.text()); } updateIksmSessionLastUsed.handler?.call(null, this.iksm_session); diff --git a/src/api/znc-proxy.ts b/src/api/znc-proxy.ts index 1a9850a..4a1fefb 100644 --- a/src/api/znc-proxy.ts +++ b/src/api/znc-proxy.ts @@ -44,7 +44,7 @@ export default class ZncProxyApi implements CoralApi { if (response.status === 204) return null!; if (response.status !== 200) { - throw new ErrorResponse('[zncproxy] Unknown error', response, await response.text()); + throw new ErrorResponse('[zncproxy] Non-200/204 status code', response, await response.text()); } const data = await response.json() as T;