Skip to content

Arbitrary properties on new createError[code || name]([msg]))? #29

@olalonde

Description

@olalonde

Would be useful if we could pass arbitrary properties to errors using constructors. e.g.:

new createError[code || name]([msg],[properties]))

this would match the createError function signature. For example, right now we can do:

  createError(402, 'Your balance is too low.', {
    detail: {
      currentBalance: 100,
      price: 150,
    },
  })

but not

  new createError.PaymentRequired('Your balance is too low.', {
    detail: {
      currentBalance: 100,
      price: 150,
    },
  })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions