Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
[fetchAuthToken] Output the full response text on failures (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Morley Zhi authored Jul 1, 2020
1 parent ad618bd commit 9496b82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 5 additions & 13 deletions src/KeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9496b82

Please sign in to comment.