Avoid ensure-error
for privacy reasons
Example: ``` > node > const nonError = {foo: 'i-am-private'}; undefined // before > util.inspect(nonError); '{ foo: \'i-am-private\' }' // after > nonError.toString() '[object Object]' > ```
This commit is contained in:
parent
ea07915e6b
commit
43b47fd349
2 changed files with 30 additions and 26 deletions
|
@ -1,7 +1,12 @@
|
|||
const ensureError = require('ensure-error');
|
||||
|
||||
// toLogFormat :: Error -> String
|
||||
exports.toLogFormat = (error) => {
|
||||
const normalizedError = ensureError(error);
|
||||
return normalizedError.stack;
|
||||
if (!error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (error && error.stack) {
|
||||
return error.stack;
|
||||
}
|
||||
|
||||
return error.toString();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue