Skip to content

Commit 5e03c90

Browse files
committed
docs: split background story and explanation [skip ci]
1 parent e532401 commit 5e03c90

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/guide/advanced/navigation-failures.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ When using `router-link`, Vue Router internally calls `router.push` to trigger a
88
- A navigation guard aborts the navigation by calling `next(false)`
99
- A navigation guard throws an error or calls `next(new Error())`
1010

11-
When using a regular `router-link`, **none of these failures will log an error**. However, if you are using `router.push` or `router.replace`, you might come across an _"Uncaught (in promise) Error"_ message followed by a more specific message in your console. This is part of the _Navigation Failures_ system in Vue Router and it is only available from version 3.2.0 onwards but existed for a long time before: through the two optional callbacks, `onComplete` and `onAbort` that can be passed to `router.push`. Since version 3.1.0, `router.push` and `router.replace` return a _Promise_ if no `onComplete`/`onAbort` callback is provided. This _Promise_ resolves instead of invoking `onComplete` and rejects instead of invoking `onAbort`.
11+
When using a regular `router-link`, **none of these failures will log an error**. However, if you are using `router.push` or `router.replace`, you might come across an _"Uncaught (in promise) Error"_ message followed by a more specific message in your console. Let's understand how to differentiate _Navigation Failures_.
12+
13+
::: tip Background story
14+
_Navigation Failures_ were exposed on version 3.2.0 but existed for a long time before: through the two optional callbacks of `router.push`, `onComplete` and `onAbort` that can be passed to `router.push`. Since version 3.1.0, `router.push` and `router.replace` return a _Promise_ if no `onComplete`/`onAbort` callback is provided. This _Promise_ resolves instead of invoking `onComplete` and rejects instead of invoking `onAbort`.
15+
:::
1216

1317
## Detecting Navigation Failures
1418

@@ -27,7 +31,7 @@ router.push('/admin').catch(failure => {
2731
```
2832

2933
::: tip
30-
If you omit the second parameter: `isNavigationFailure(failure)`, it will only check if the error comes from the Router.
34+
If you omit the second parameter: `isNavigationFailure(failure)`, it will only check if the error is a _Navigation Failure_.
3135
:::
3236

3337
## `NavigationFailureType`

0 commit comments

Comments
 (0)