Skip to content

Commit

Permalink
[Notifier] added better error descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Dec 9, 2015
1 parent d054985 commit 9efd34b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ui/public/courier/fetch/request/_error_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions src/ui/public/notify/lib/_format_msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ': ';
Expand All @@ -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;
});
2 changes: 2 additions & 0 deletions src/ui/public/notify/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ define(function (require) {
}, cb);
};

Notifier.prototype.describeError = formatMsg.describeError;

if (log === _.noop) {
Notifier.prototype.log = _.noop;
} else {
Expand Down

0 comments on commit 9efd34b

Please sign in to comment.