Skip to content

RouterErrorCode ​

The route error code enum. Its values are aligned with vue-router 4's NavigationFailureType, with additional uni-app x platform-specific error codes.

ts
import { RouterErrorCode } from '@meng-xi/unix-router'
Error codeValueTrigger scenario
ABORTED4A guard returned false, aborting the navigation (including a non-positive-integer delta for back())
CANCELLED8A guard threw an Error, guard timeout (guardTimeout default 10000ms), redirect exceeded the max depth (10), or back() with an insufficient page stack
DUPLICATED16Repeatedly push to the current address (path+query+params+hash all identical to current; checked by push only)
ROUTE_NOT_FOUND32No route matched (a name not registered in strict mode) or an invalid location (uni-app x extension)
NAVIGATION_API_ERROR64A uni.* native navigation API call failed, or the page-stack-top confirmation failed after navigation completed (uni-app x extension)
SETUP_ERROR128Router installation environment error (uni-app x extension). Reserved code — not thrown by the current version.
PLUGIN_REQUIRED256Using a plugin capability without registering the corresponding plugin (e.g. using params without ParamsPlugin, or events without EventsPlugin) (uni-app x extension)

How to check

Pair with isNavigationFailure(error, type?) to narrow the check, or compare directly (failure.code === RouterErrorCode.ROUTE_NOT_FOUND). The to / from fields of NavigationFailure help locate the failure context further.

Released under the MIT License.