mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 10:23:14 -04:00
[Notifier] added better error descriptions
This commit is contained in:
parent
d054985eed
commit
9efd34bc69
3 changed files with 14 additions and 3 deletions
|
@ -14,7 +14,7 @@ define(function (require) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!myHandlers.length) {
|
if (!myHandlers.length) {
|
||||||
notify.fatal(new Error('unhandled error ' + (error.stack || error.message)));
|
notify.fatal(new Error(`unhandled courier request error: ${ notify.describeError(error) }`));
|
||||||
} else {
|
} else {
|
||||||
myHandlers.forEach(function (handler) {
|
myHandlers.forEach(function (handler) {
|
||||||
handler.defer.resolve(error);
|
handler.defer.resolve(error);
|
||||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
||||||
* @param {String} from - Prefix for message indicating source (optional)
|
* @param {String} from - Prefix for message indicating source (optional)
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
return function formatMsg(err, from) {
|
function formatMsg(err, from) {
|
||||||
var rtn = '';
|
var rtn = '';
|
||||||
if (from) {
|
if (from) {
|
||||||
rtn += from + ': ';
|
rtn += from + ': ';
|
||||||
|
@ -21,9 +21,18 @@ define(function (require) {
|
||||||
} else if (esMsg) {
|
} else if (esMsg) {
|
||||||
rtn += esMsg;
|
rtn += esMsg;
|
||||||
} else if (err instanceof Error) {
|
} else if (err instanceof Error) {
|
||||||
rtn += err.message;
|
rtn += formatMsg.describeError(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formatMsg.describeError = function (err) {
|
||||||
|
if (!err) return undefined;
|
||||||
|
if (err.body && err.body.message) return err.body.message;
|
||||||
|
if (err.message) return err.message;
|
||||||
|
return '' + err;
|
||||||
|
};
|
||||||
|
|
||||||
|
return formatMsg;
|
||||||
});
|
});
|
||||||
|
|
|
@ -267,6 +267,8 @@ define(function (require) {
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Notifier.prototype.describeError = formatMsg.describeError;
|
||||||
|
|
||||||
if (log === _.noop) {
|
if (log === _.noop) {
|
||||||
Notifier.prototype.log = _.noop;
|
Notifier.prototype.log = _.noop;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue