3.0.1
https://router.vuejs.org/en/installation.html#
Look at the docs
Try to find a mention of onError that describes appropriate usage.
Fail to find it.
Documentation of this method
Documentation of this method is not present
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:
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.
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
Most helpful comment
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: