Kind: Class
Source: src/router.ts
Error class representing an unsupported path error.
UnsupportedPathError represents a path that the router cannot handle. It lets routing callers distinguish unsupported-path failures from other errors and return an appropriate response.
Extends: Error
Diagram
mermaidgraph LR RequestPath[Requested path] --> Router Router -->|Path is unsupported| UnsupportedPathError UnsupportedPathError --> Caller[Route caller or error handler]
Usage
tsimport { UnsupportedPathError } from "./router";
try {
const result = resolveRoute(requestPath);
return result;
} catch (error) {
if (error instanceof UnsupportedPathError) {
return {
status: 404,
message: "The requested path is not supported.",
};
}
throw error;
}
AI Coding Instructions
- Throw
UnsupportedPathErrorwhen router path validation determines that a path cannot be handled. - Check errors with
instanceof UnsupportedPathErrorinstead of matching error-message text. - Handle this error at the router boundary or request handler where an unsupported path can be mapped to an application response.
- Do not replace this error with a generic
Errorwhen callers need to distinguish routing failures.
Used by
4 references from 4 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (4)
LinearRouter—src/router/linear-router/router.ts:11PatternRouter—src/router/pattern-router/router.ts:8RegExpRouter—src/router/reg-exp-router/router.ts:47SmartRouter—src/router/smart-router/router.ts:4
Was this page helpful?