Skip to content

[feature] createError additional (optional) data #464

Description

@maxdzin

Problem or motivation

I just started to integrate this lib into some Nuxt projects and it fits very well, so I want to thank you for such a great thing.
However, in some cases I missed possibility to pass more data through createError to the client side - now it allows to put just a limited set of parameters, such as cause, fix, etc.

Proposed feature

Enhance ErrorOptions passed to createError with extra object parameter (or maybe there's better name for it), which can include custom data passed to the client side.
Plus, sometimes it would be good to allow to pass the cause not only as Error object, but maybe as H3Error.

Possible implementation (optional)

Make ErrorOptions interface as follows:

interface ErrorOptions<DataT = unknown, ErrorT = Error> {
  ...

  /** The original error that caused this */
  cause?: ErrorT;

  /** Additional data to be included in response */
  extra?: DataT
}

and to make ErrorLog to include that additional data.

Alternatives you’ve considered (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions