Merge pull request #5611 from spalger/implement/betterErrorReading

Implement/better error reading
This commit is contained in:
Spencer 2015-12-09 11:12:13 -07:00
commit 9a9d09b1d9
3 changed files with 14 additions and 3 deletions

View file

@ -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);

View file

@ -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;
});

View file

@ -267,6 +267,8 @@ define(function (require) {
}, cb);
};
Notifier.prototype.describeError = formatMsg.describeError;
if (log === _.noop) {
Notifier.prototype.log = _.noop;
} else {