> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Resource Errors

> Errors thrown during resource lookup, reading, and URI validation.

## Overview

Resource errors cover failures related to MCP resources — not found, read failures, and invalid URIs. `ResourceNotFoundError` includes a custom `toJsonRpcError()` method that returns an MCP-compliant JSON-RPC error with the resource URI.

## Error Reference

### ResourceNotFoundError

Thrown when a requested resource URI does not match any registered resource.

| Property       | Type      | Value                |
| -------------- | --------- | -------------------- |
| `code`         | `string`  | `RESOURCE_NOT_FOUND` |
| `statusCode`   | `number`  | `404`                |
| `isPublic`     | `boolean` | `true`               |
| `uri`          | `string`  | The requested URI    |
| `mcpErrorCode` | `number`  | `-32002`             |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ResourceNotFoundError(uri: string)
```

**JSON-RPC format:**

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
error.toJsonRpcError();
// { code: -32002, message: "Resource not found: file:///missing.txt", data: { uri: "file:///missing.txt" } }
```

**Example:**

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { ResourceNotFoundError } from '@frontmcp/sdk';

throw new ResourceNotFoundError('file:///missing.txt');
```

***

### ResourceReadError

Thrown when reading a resource fails. This is an internal error — details are hidden from clients.

| Property        | Type                 | Value                 |
| --------------- | -------------------- | --------------------- |
| `code`          | `string`             | `RESOURCE_READ_ERROR` |
| `statusCode`    | `number`             | `500`                 |
| `isPublic`      | `boolean`            | `false`               |
| `originalError` | `Error \| undefined` | The underlying cause  |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ResourceReadError(uri: string, originalError?: Error)
```

**Example:**

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { ResourceReadError } from '@frontmcp/sdk';

try {
  const data = await fs.readFile(path);
} catch (error) {
  throw new ResourceReadError('file:///data.json', error);
}
```

***

### InvalidResourceUriError

Thrown when a resource URI does not conform to RFC 3986 or is otherwise malformed.

| Property     | Type      | Value                  |
| ------------ | --------- | ---------------------- |
| `code`       | `string`  | `INVALID_RESOURCE_URI` |
| `statusCode` | `number`  | `400`                  |
| `isPublic`   | `boolean` | `true`                 |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new InvalidResourceUriError(uri: string, reason?: string)
```

**Example:**

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { InvalidResourceUriError } from '@frontmcp/sdk';

throw new InvalidResourceUriError('no-scheme', 'URI must have a valid scheme');
```
