From 98fd83962a0b2adecf1697254eba31984945acd2 Mon Sep 17 00:00:00 2001 From: Akiomi Kamakura Date: Wed, 10 Nov 2021 18:45:03 +0900 Subject: [PATCH 1/2] Add v3-style testing apikey error suuport --- src/api/http-error.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/http-error.ts b/src/api/http-error.ts index 509c1df..87cf247 100644 --- a/src/api/http-error.ts +++ b/src/api/http-error.ts @@ -12,7 +12,9 @@ export class HttpError implements Error { return ( content === '{"message":"Testing Apikey is only allowed to ticker ending with \\"01\\""}' || - content === '{"message":"Testing apikey is not allowed"}' + content === '{"message":"Testing apikey is not allowed"}' || + content === + '{"message":"Trial request only supports ticker ending \'01\'"}' ) } From bfdf6b2e89a7fce8e54032ee6adae12d3fef2c9f Mon Sep 17 00:00:00 2001 From: Akiomi Kamakura Date: Wed, 10 Nov 2021 18:48:25 +0900 Subject: [PATCH 2/2] Add 403 handling --- src/api/http-error.ts | 5 +++++ src/custom-functions/v2/bcode.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/http-error.ts b/src/api/http-error.ts index 87cf247..6e6e637 100644 --- a/src/api/http-error.ts +++ b/src/api/http-error.ts @@ -18,6 +18,11 @@ export class HttpError implements Error { ) } + public isInvalidTokenRequest(): boolean { + const content = this.response.getContentText() + return content === '{"message":"Forbidden"}' + } + public toString(): string { return this.message } diff --git a/src/custom-functions/v2/bcode.ts b/src/custom-functions/v2/bcode.ts index 7b320dd..b91fd9a 100644 --- a/src/custom-functions/v2/bcode.ts +++ b/src/custom-functions/v2/bcode.ts @@ -95,8 +95,10 @@ export function bcode( if (e.isInvalidTestingRequest()) { throw new Error('<<テスト用のAPIキーでは取得できないデータです>>') - } else if (code === 403) { + } else if (e.isInvalidTokenRequest()) { throw new Error('<>') + } else if (code === 403) { + throw new Error('<<月間リクエスト制限に達しています>>') } else if (code === 429) { throw new Error('<>') } else if (Math.floor(code / 100) === 4) {