Skip to content

onError is undocumented #1973

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

Closed
dancrumb opened this issue Jan 8, 2018 · 2 comments
Closed

onError is undocumented #1973

dancrumb opened this issue Jan 8, 2018 · 2 comments

Comments

@dancrumb
Copy link
Contributor

dancrumb commented Jan 8, 2018

Version

3.0.1

Reproduction link

https://router.vuejs.org/en/installation.html#

Steps to reproduce

Look at the docs
Try to find a mention of onError that describes appropriate usage.
Fail to find it.

What is expected?

Documentation of this method

What is actually happening?

Documentation of this method is not present

@posva posva closed this as completed in 81e6ce0 Jan 8, 2018
@kwbBaker
Copy link

kwbBaker commented Oct 3, 2018

Why was this closed? I've just been dealing with this exact same issue in vue-router 3.0.1 and can assure you it is not fixed. The documentation covers onError here: https://router.vuejs.org/api/#router-onerror but there is absolutely no mention of any expected usage, and it even suggests that it is purely a no-argument callback that you must provide. I see from examples and discussions on-line that people treat it as a callback that is to take some sort of error parameter when it is called, but the documentation is completely silent on the matter. This is all it says:

router.onError

Signature:

router.onError(callback)

Register a callback which will be called when an error is caught during a route navigation. Note for an error to be called, it must be one of the following scenarios:

The error is thrown synchronously inside a route guard function;

The error is caught and asynchronously handled by calling next(err) inside a route guard function;

An error occurred when trying to resolve an async component that is required to render a route.

@candu
Copy link

candu commented Jan 29, 2020

Agree with @kwbskf here - the documentation could be more specific as to what's expected here.

For anyone else coming to this issue: I don't unfortunately have time right now to navigate the vue-router docs PR process, but I did track down the expected callback signature in router.d.ts:

type ErrorHandler = (err: Error) => void
onError(cb: ErrorHandler): void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants