Defines an error that is thrown when the resolving URL does not match any pattern known by the router.

This error cannot be handled by the RouterOptions.errorHandler. To handle this error, you should create a route that consumes all possible URLs and place it at the end of the routes list. This way, if the preceding routes are unable to handle the URL, it will be handled by this route, and the NotFoundError will never be thrown.

const router = new Router<string>([
{
path: '/foo',
},
{
action() { console.log('404: Page not found'); },
path: '*',
}
]);

await router.resolve('/foo/bar');

The example above will print the following message in the console:

404: Page not found

Hierarchy

  • Error
    • NotFoundError

Constructors

Properties

prepareStackTrace?: ((err: Error, stackTraces: CallSite[]) => any)

Optional override for formatting stack traces

stackTraceLimit: number
cause?: unknown
name: string
message: string
stack?: string

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void