mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
b65dea4f03
This allows developers to throw a `RedirectCommand` directly from guards and resolvers to trigger a redirect. The primary benefit is that we no longer need to pollute the return type of functions that redirect. For example, a deeply nested helper function or a resolver can now simply throw a `RedirectCommand` to short-circuit and redirect, instead of having to return the `UrlTree` or `RedirectCommand` all the way up the call stack. This aligns with prior art in other modern framework routers (such as Next.js, Remix, and SvelteKit), which commonly use thrown exceptions or special redirect responses to abort execution and trigger immediate redirection.