Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform errors into plain objects since they don't stringify well #777

Merged
merged 1 commit into from
Feb 20, 2016
Merged

Transform errors into plain objects since they don't stringify well #777

merged 1 commit into from
Feb 20, 2016

Conversation

Sebmaster
Copy link
Contributor

I haven't found any output tests or I would've added one. Anyways - this restores proper error output behaviour.

log('msg', { error: err }) still doesn't work because of cycle.js, but log('msg', err) now returns

2015-12-21T20:23:43.904Z - error: [26934] msg Error: ha
    at null._onTimeout (/path/to/my.js:14:13)
    at Timer.listOnTimeout (timers.js:92:15)

In json mode:

{
  "message": "msg",
  "stack": "Error: ha\n    at null._onTimeout (/path/to/my/js:14:13)\n    at Timer.listOnTimeout (timers.js:92:15)",
  "level": "error",
  "label": "27635",
  "timestamp": "2015-12-21T20:29:15.983Z"
}

(There were no traces of either error.message, nor error.stack before.)

@alexandrubau
Copy link

Does it also work with other objects? Not just Errors.

@indexzero
Copy link
Member

I see where you are going with this fix, but there is no need for a new function. Just add this logic into exports.clone.

@Sebmaster
Copy link
Contributor Author

Fixed, I'd like to get nested error objects working too, but that'll probably have to wait a bit.

@indexzero
Copy link
Member

This makes a lot more sense to me.

indexzero added a commit that referenced this pull request Feb 20, 2016
Transform errors into plain objects since they don't stringify well
@indexzero indexzero merged commit 85ade33 into winstonjs:master Feb 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants