From 67982af35a3300542fa724612169b4b4fe7ba333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Sat, 9 Jun 2018 11:33:14 +0200 Subject: [PATCH] Fix error display --- src/api/Ledger.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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