Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't swallow Error message/stack when using formatter
Fixes winstonjs#1178 When we use a formatter and pass an `Error` object in as `meta`, we end up removing the Error's message and stack information when `decycle`ing it. `clone` checks if the passed-in object is an `Error` and does not `decycle` it in that case, but when we use a formatter, this check does not happen because we `clone` the whole `options` object instead of just cloning `options.meta`. Simply removing the `&& !(options.meta instanceof Error)` from this line fixes the problem, by forcing it to `clone` `meta` the first time, when the `instanceof Error` check will catch it and copy `message` and `stack` into a new, non-Error object. So when that's buried in `options.meta`, re-`clone`ing it won't hurt. EDIT: this appears to (possibly negatively) affect code further down in the function, where we check if `meta instanceof Error`, so is maye not a good solution.
- Loading branch information