From 9496b82d909dfce9a7304a2b5dd544be1f5f9fdd Mon Sep 17 00:00:00 2001 From: Morley Zhi Date: Wed, 1 Jul 2020 16:56:17 -0400 Subject: [PATCH] [fetchAuthToken] Output the full response text on failures (#158) --- package.json | 2 +- src/KeyManager.ts | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 98349d5c..12045269 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stellar/wallet-sdk", - "version": "0.1.0-rc.2", + "version": "0.1.0-rc.3", "description": "Libraries to help you write Stellar-enabled wallets in Javascript", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/KeyManager.ts b/src/KeyManager.ts index a24992c6..3e97600a 100644 --- a/src/KeyManager.ts +++ b/src/KeyManager.ts @@ -317,19 +317,11 @@ export class KeyManager { ); if (challengeRes.status !== 200) { - try { - const challengeJson = await challengeRes.json(); - throw new Error( - `[KeyManager#fetchAuthToken] Failed to fetch a challenge transaction, - error: ${challengeJson.error}`, - ); - } catch (e) { - throw new Error( - `[KeyManager#fetchAuthToken] Failed to fetch a challenge transaction, - error code ${challengeRes.status} and status text - "${challengeRes.statusText}"`, - ); - } + const challengeText = await challengeRes.text(); + throw new Error( + `[KeyManager#fetchAuthToken] Failed to fetch a challenge transaction, + error: ${JSON.stringify(challengeText)}`, + ); } const keyNetwork = key.network || this.defaultNetworkPassphrase;