mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Merge pull request #5611 from spalger/implement/betterErrorReading
Implement/better error reading
This commit is contained in:
commit
9a9d09b1d9
3 changed files with 14 additions and 3 deletions
|
@ -14,7 +14,7 @@ define(function (require) {
|
|||
});
|
||||
|
||||
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 {
|
||||
myHandlers.forEach(function (handler) {
|
||||
handler.defer.resolve(error);
|
||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
|||
* @param {String} from - Prefix for message indicating source (optional)
|
||||
* @returns {string}
|
||||
*/
|
||||
return function formatMsg(err, from) {
|
||||
function formatMsg(err, from) {
|
||||
var rtn = '';
|
||||
if (from) {
|
||||
rtn += from + ': ';
|
||||
|
@ -21,9 +21,18 @@ define(function (require) {
|
|||
} else if (esMsg) {
|
||||
rtn += esMsg;
|
||||
} else if (err instanceof Error) {
|
||||
rtn += err.message;
|
||||
rtn += formatMsg.describeError(err);
|
||||
}
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
Notifier.prototype.describeError = formatMsg.describeError;
|
||||
|
||||
if (log === _.noop) {
|
||||
Notifier.prototype.log = _.noop;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue