Skip to content

--consolelogs serialization does not work for Errors  #152

Open

Description

@imhoffd

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)

Activity

  1. added
    bug
    on Jun 19, 2019
  2. joshstrange commented on Jun 19, 2019

    @joshstrange

    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
      }
    }
    
  3. imhoffd commented on Jun 19, 2019

    @imhoffd
    ContributorAuthor

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

  4. joshstrange commented on Jun 19, 2019

    @joshstrange

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions