normalize bws error message
This commit is contained in:
parent
6df65b541d
commit
53a22dcd20
1 changed files with 37 additions and 34 deletions
|
|
@ -3,12 +3,12 @@ angular.module('copayApp.services')
|
||||||
.factory('bwsError', function bwcErrorService($log, gettextCatalog) {
|
.factory('bwsError', function bwcErrorService($log, gettextCatalog) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
root.msg = function(err, prefix) {
|
root.msg = function(err, prefix) {
|
||||||
var body = '';
|
var body = '';
|
||||||
prefix = prefix || '';
|
prefix = prefix || '';
|
||||||
|
|
||||||
if (err && err.code) {
|
if (err && err.code) {
|
||||||
switch(err.code) {
|
switch (err.code) {
|
||||||
case 'CONNECTION_ERROR':
|
case 'CONNECTION_ERROR':
|
||||||
body = gettextCatalog.getString('Network connection error');
|
body = gettextCatalog.getString('Network connection error');
|
||||||
break;
|
break;
|
||||||
|
|
@ -96,6 +96,9 @@ angular.module('copayApp.services')
|
||||||
case 'MAIN_ADDRESS_GAP_REACHED':
|
case 'MAIN_ADDRESS_GAP_REACHED':
|
||||||
body = gettextCatalog.getString('Empty addresses limit reached. New addresses cannot be generated.');
|
body = gettextCatalog.getString('Empty addresses limit reached. New addresses cannot be generated.');
|
||||||
break;
|
break;
|
||||||
|
case 'WALLET_LOCKED':
|
||||||
|
body = gettextCatalog.getString('Wallet is locked');
|
||||||
|
break;
|
||||||
|
|
||||||
case 'ERROR':
|
case 'ERROR':
|
||||||
body = (err.message || err.error);
|
body = (err.message || err.error);
|
||||||
|
|
@ -103,7 +106,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$log.warn('Unknown error type:', err.code);
|
$log.warn('Unknown error type:', err.code);
|
||||||
body = err.message || err.code;
|
body = err.message || err.code;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (err.message) {
|
} else if (err.message) {
|
||||||
|
|
@ -112,11 +115,11 @@ angular.module('copayApp.services')
|
||||||
body = gettextCatalog.getString(err);
|
body = gettextCatalog.getString(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = prefix + ( body ? (prefix ? ': ' : '') + body : '');
|
var msg = prefix + (body ? (prefix ? ': ' : '') + body : '');
|
||||||
return msg;
|
return msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.cb = function (err,prefix, cb) {
|
root.cb = function(err, prefix, cb) {
|
||||||
return cb(root.msg(err, prefix))
|
return cb(root.msg(err, prefix))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue