Fix: Allow proper logging of node.js Error objects.

See: https://github.com/bluejamesbond/Scribe.js/issues/70
This commit is contained in:
baldo 2017-05-13 11:38:25 +02:00
parent 744281751e
commit 6214404b64

View file

@ -42,6 +42,20 @@ angular.module('ffffng').factory('Logger', function (app) {
app.use(prefix + '/internal/logs', scribe.webPanel());
}
// Hack to allow correct logging of node.js Error objects.
// See: https://github.com/bluejamesbond/Scribe.js/issues/70
Object.defineProperty(Error.prototype, 'toJSON', {
configurable: true,
value: function () {
var alt = {};
var storeKey = function (key) {
alt[key] = this[key];
};
Object.getOwnPropertyNames(this).forEach(storeKey, this);
return alt;
}
});
return process.console;
});