Skip to content

UnsupportedPathError

reference
1 min readUpdated

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

mermaid
graph LR
  RequestPath[Requested path] --> Router
  Router -->|Path is unsupported| UnsupportedPathError
  UnsupportedPathError --> Caller[Route caller or error handler]

Usage

ts
import { 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 UnsupportedPathError when router path validation determines that a path cannot be handled.
  • Check errors with instanceof UnsupportedPathError instead 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 Error when 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)

  • LinearRoutersrc/router/linear-router/router.ts:11
  • PatternRoutersrc/router/pattern-router/router.ts:8
  • RegExpRoutersrc/router/reg-exp-router/router.ts:47
  • SmartRoutersrc/router/smart-router/router.ts:4

Was this page helpful?

Download as PDF
UnsupportedPathError — Hono (narrator proof)