# UnsupportedPathError

**Kind:** Class

**Source:** [`src/router.ts`](https://github.com/honojs/hono/blob/main/src/router.ts#L103)

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)

- `LinearRouter` — `src/router/linear-router/router.ts`:11
- `PatternRouter` — `src/router/pattern-router/router.ts`:8
- `RegExpRouter` — `src/router/reg-exp-router/router.ts`:47
- `SmartRouter` — `src/router/smart-router/router.ts`:4
