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

--consolelogs serialization does not work for Errors #152

Open
imhoffd opened this issue Jun 19, 2019 · 3 comments
Open

--consolelogs serialization does not work for Errors #152

imhoffd opened this issue Jun 19, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@imhoffd
Copy link
Contributor

imhoffd commented Jun 19, 2019

There should be some sort of stringification here, otherwise Error instances fail to serialize:

msg.data.push(arguments[i]);

ref: ionic-team/ionic-cli#3169 (comment)

@joshstrange
Copy link

Not sure if this will fix everything but here is the quick hack I did to output thrown errors:

if (arguments[i] instanceof Error) {
  arguments[i] = {
    name: arguments[i].name,
    message: arguments[i].message
  }
}

@imhoffd
Copy link
Contributor Author

imhoffd commented Jun 19, 2019

@joshstrange I usually do something like this for errors: err.stack ? err.stack : err.toString()

@joshstrange
Copy link

@dwieeb Yeah I think the issue was circular dependencies but I can't be sure. I had no issue passing the stack as well but didn't because it's in the message. I played around with a number of approaches and actually had it working perfectly using the code from serialize-error but it was too busy and so after going through all the keys and looking for useful info I settled on name and message.

There is a bunch of stuff that is added (by angular? I think) that is just noise. It might be a better idea to pair down the error instead of building up an object like I did that way if users have custom errors with extra keys they can be sent back to the terminal as well. Idk, food for thought. Thank you for all your help @dwieeb I REALLY appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants