-
Notifications
You must be signed in to change notification settings - Fork 26.3k
fix(router): Align RouterModule.forRoot errorHandler with provider error handler #57050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
TGP is green with local changes needed from cl/658542550 |
…ror handler This change aligns the behavior of the error handler in the `ExtraOptions` of `RouterModule.forRoot` with the error handler in `withNavigationErrorHandler`. The changes are: * Slightly different timing: The handler is called before the `NavigationError` emits * Runs in the injection context, meaning it is more configurable at the config location rather than needing to assign the value to the `Router.errorHandler` later to get access to injectables * Can now return `RedirectCommand` to recover from the error and redirect without emitting `NavigationError` * No longer allows arbitrarily overriding return value of the navigation promise BREAKING CHANGE: The `Router.errorHandler` property has been removed. Adding an error handler should be configured in either `withNavigationErrorHandler` with `provideRouter` or the `errorHandler` property in the extra options of `RouterModule.forRoot`. In addition, the error handler cannot be used to change the return value of the router navigation promise or prevent it from rejecting. Instead, if you want to prevent the promise from rejecting, use `resolveNavigationPromiseOnError`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
🎉 for cleaning up deprecations!
caretaker note: please patch in the changes to the ssr router in cl/658542550 |
This PR was merged into the repository by commit b279081. The changes were merged into the following branches: main |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This change aligns the behavior of the error handler in the
ExtraOptions
ofRouterModule.forRoot
with the error handler inwithNavigationErrorHandler
. The changes are:NavigationError
emitsRouter.errorHandler
later to get access to injectablesRedirectCommand
to recover from the error and redirect without emittingNavigationError
BREAKING CHANGE: The
Router.errorHandler
property has been removed. Adding an error handler should be configured in eitherwithNavigationErrorHandler
withprovideRouter
or theerrorHandler
property in the extra options ofRouterModule.forRoot
. In addition, the error handler cannot be used to change the return value of the router navigation promise or prevent it from rejecting. Instead, if you want to prevent the promise from rejecting, useresolveNavigationPromiseOnError
.