Skip to content

Handle Promise rejection in guards #2833

Open
@posva

Description

@posva

Version

3.0.3

Reproduction link

https://jsfiddle.net/orzwg537/

Steps to reproduce

Run the fiddle and look in console

What is expected?

a message saying error caught

What is actually happening?

There is an Unhandled Promise rejection instead


Currently, errors thrown in guards are caught by router.onError but Promises rejections (or error thrown in an async function) are not caught. This should be handled in all the other guards as well. To handle them right now it is possible by passing the error to next:

try {
  await fetchdata()
} catch (error) {
  next(error)
}

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