• Overview
@angular/router

withNavigationErrorHandler

function

Provides a function which is called when a navigation error occurs.

withNavigationErrorHandler

Provides a function which is called when a navigation error occurs.

This function is run inside application's injection context so you can use the inject function.

This function can return a RedirectCommand to convert the error to a redirect, similar to returning a UrlTree or RedirectCommand from a guard. This will also prevent the Router from emitting NavigationError; it will instead emit NavigationCancel with code NavigationCancellationCode.Redirect. Return values other than RedirectCommand are ignored and do not change any behavior with respect to how the Router handles the error.

@paramhandler(error: NavigationError) => unknown
Jump to details