AK0052
Route guard threw an error
What happened
A route guard (e.g., beforeEnter, beforeLeave) threw an unhandled exception during navigation. This prevented the route transition from completing.
How to fix
Add error handling in your guard function. Wrap async logic in try/catch and return a clear result (allow, redirect, or deny).
Example
ts
// Bad — guard can throw unexpectedly
const routes = [
{
path: "/dashboard",
component: Dashboard,
beforeEnter: async () => {
const user = await fetchUser(); // might throw!
return user.isAdmin;
},
},
];
// Good — handle errors in the guard
const routes = [
{
path: "/dashboard",
component: Dashboard,
beforeEnter: async () => {
try {
const user = await fetchUser();
return user.isAdmin;
} catch {
return "/login"; // redirect on failure
}
},
},
];