Skip to content

Behavior when object is an error instances #2

Open

Description

@mhofman

What should the behavior of Error.captureStackTrace be when the object provided is an object with an [[ErrorData]] slot?

My preference right now would be to reset the internal error stack info, but not add a new private field or own stack property (this is partially assuming that we standardize a prototype stack property for Errors in https://github.com/tc39/proposal-error-stacks)

Activity

  1. mgaudet commented on Dec 6, 2024

    @mgaudet
    Collaborator

    I think my current implementation simply does [[Define]] a new property -- my current implementation doesn't do anything special with the [[ErrorData]] slot.

    • As a result you'll get a string valued own property "stack" on the provided object with the truncated stack string.
    • Using the prototype getter you could still get the un-truncated stack (and if we have code in let's say devtools that explicitly manipulates [[ErrorData]] (no idea if we do) they would ignore the own property. d

    For the SES purposes, since both Error.prototype.stack and Error.captureStack trace are deniable, I think this is fine behaviour.

  2. mhofman commented on Dec 6, 2024

    @mhofman
    MemberAuthor

    Yeah it might be fine for a data property. Just slightly worried about the consistency of stacks depending on how you consume them.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions