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:
Daniel Gasienica 2018-03-08 14:06:22 -05:00
parent ea07915e6b
commit 43b47fd349
2 changed files with 30 additions and 26 deletions

View file

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