diff --git a/src/helpers/init-libcore.js b/src/helpers/init-libcore.js index f1df2ee0..70e3e632 100644 --- a/src/helpers/init-libcore.js +++ b/src/helpers/init-libcore.js @@ -3,6 +3,7 @@ import logger from 'logger' import invariant from 'invariant' import network from 'api/network' +import { serializeError } from './errors' const lib = require('@ledgerhq/ledger-core') @@ -96,7 +97,7 @@ const NJSHttpClient = new lib.NJSHttpClient({ r.complete(urlConnection, null) } catch (err) { const urlConnection = createHttpConnection(res, err.message) - r.complete(urlConnection, { code: 0, message: err.message }) + r.complete(urlConnection, { code: 0, message: JSON.stringify(serializeError(err)) }) } }, }) diff --git a/src/helpers/libcore.js b/src/helpers/libcore.js index e42bf774..7628c4c8 100644 --- a/src/helpers/libcore.js +++ b/src/helpers/libcore.js @@ -11,8 +11,7 @@ import type { NJSAccount, NJSOperation } from '@ledgerhq/ledger-core/src/ledgerc import { isSegwitAccount } from 'helpers/bip32' import * as accountIdHelper from 'helpers/accountId' -import { createCustomErrorClass } from './errors' - +import { createCustomErrorClass, deserializeError } from './errors' import { getAccountPlaceholderName, getNewAccountPlaceholderName } from './accountName' const NoAddressesFound = createCustomErrorClass('NoAddressesFound') @@ -158,7 +157,11 @@ const coreSyncAccount = (core, account) => (payload && payload.getString('EV_SYNC_ERROR_MESSAGE')) || 'Sync failed' ).replace(' (EC_PRIV_KEY_INVALID_FORMAT)', '') - reject(new Error(message)) + try { + reject(deserializeError(JSON.parse(message))) + } catch (e) { + reject(message) + } return } if (