Kind: Constant
Source: src/router.ts
Error message indicating that a route cannot be added because the matcher is already built.
MESSAGE_MATCHER_IS_ALREADY_BUILT stores the error message used when code attempts to add a route after its matcher has been built. It keeps this validation message consistent within src/router.ts when route configuration occurs in the wrong order.
Definition
ts'Can not add a route since the matcher is already built.'
Value
ts'Can not add a route since the matcher is already built.'
Diagram
mermaidgraph LR A[Add route] --> B{Matcher built?} B -- No --> C[Register route] B -- Yes --> D[MESSAGE_MATCHER_IS_ALREADY_BUILT] D --> E[Throw error]
Usage
tsimport { MESSAGE_MATCHER_IS_ALREADY_BUILT } from "./router";
function addRoute(matcherBuilt: boolean) {
if (matcherBuilt) {
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
}
// Register the route before building the matcher.
}
AI Coding Instructions
- Use
MESSAGE_MATCHER_IS_ALREADY_BUILTinstead of duplicating the matcher-built error text. - Check matcher build state before registering a new route.
- Add routes before the router builds its matcher.
- Keep errors related to route registration in
src/router.tsaligned with this constant.
Used by
2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (2)
RegExpRouter—src/router/reg-exp-router/router.ts:47SmartRouter—src/router/smart-router/router.ts:4
Was this page helpful?