diff --git a/src/api/Ledger.js b/src/api/Ledger.js index c68aa590..ea5572bc 100644 --- a/src/api/Ledger.js +++ b/src/api/Ledger.js @@ -11,14 +11,14 @@ export const userFriendlyError = (p: Promise): Promise => // that falls out of the range of 2xx const { data } = error.response if (data && typeof data.error === 'string') { - const msg = data.error || data.message + let msg = data.error || data.message if (typeof msg === 'string') { const m = msg.match(/^JsDefined\((.*)\)$/) if (m) { try { const { message } = JSON.parse(m[1]) if (typeof message === 'string') { - throw new Error(message) + msg = message } } catch (e) { logger.warn("can't parse server result", e) @@ -28,7 +28,7 @@ export const userFriendlyError = (p: Promise): Promise => } } logger.log('Ledger API: HTTP status', error.response.status, 'data: ', error.response.data) - throw new Error('A problem occurred with Ledger Servers. Please try again later.') + throw new Error('A problem occurred with Ledger API. Please try again later.') } else if (error.request) { // The request was made but no response was received // `error.request` is an instance of XMLHttpRequest in the browser and an instance of