diff --git a/src/api/network.js b/src/api/network.js
index b4bfb76d..cc0bf83d 100644
--- a/src/api/network.js
+++ b/src/api/network.js
@@ -19,16 +19,20 @@ const userFriendlyError = (p: Promise): Promise =>
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') {
- msg = message
- }
- } catch (e) {
- logger.warn("can't parse server result", e)
+ const innerPart = m ? m[1] : msg
+ try {
+ const r = JSON.parse(innerPart)
+ let message = r.error
+ if (typeof message === 'object') {
+ message = message.message
}
+ if (typeof message === 'string') {
+ msg = message
+ }
+ } catch (e) {
+ logger.warn("can't parse server result", e)
}
+
if (msg && msg[0] !== '<') {
throw new LedgerAPIErrorWithMessage(msg)
}