Skip to content

Make handleError async #7756

@vekunz

Description

@vekunz

Describe the problem

I want to use the handleError hook of SvelteKit, but I realized that it currently has to be a synchronous function. But unfortunately, our error mapper is an asynchronous function. Since it is not possible in JavaScript to synchronously await an asynchronous function (like in C#), it seems we cannot use the handleError hook currently.

Describe the proposed solution

Make the return type of HandleServerError and HandleClientError a MaybePromise, like the handle-hook.

export interface HandleServerError {
  (input: { error: unknown; event: RequestEvent }): MaybePromise<void | App.Error>;
}

export interface HandleClientError {
  (input: { error: unknown; event: NavigationEvent }): MaybePromise<void | App.Error>;
}

Alternatives considered

Continue not to use handleError.

Importance

would make my life easier

Additional Information

No response

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