angular-toolkit
angular-toolkit copied to clipboard
--consolelogs serialization does not work for Errors
There should be some sort of stringification here, otherwise Error instances fail to serialize:
https://github.com/ionic-team/angular-toolkit/blob/07af9068b8b5418ad3f14048ffd8879e861aea92/assets/consolelogs.js#L56
ref: https://github.com/ionic-team/ionic-cli/issues/3169#issuecomment-503619239
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
}
}
@joshstrange I usually do something like this for errors: err.stack ? err.stack : err.toString()
@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.