Browse Source

serialize error that go through libcore as well

this help for translated errors
master
Gaëtan Renaudeau 7 years ago
parent
commit
7f4d833ce9
  1. 3
      src/helpers/init-libcore.js
  2. 9
      src/helpers/libcore.js

3
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)) })
}
},
})

9
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 (

Loading…
Cancel
Save