> ## 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.

# Provider Errors

> Errors for dependency injection, provider resolution, and scope management.

## Overview

Provider errors are thrown by the FrontMCP dependency injection system. They cover unregistered providers, scope mismatches, construction failures, circular dependencies, and plugin dependency issues. All provider errors are internal errors.

## Error Reference

### ProviderNotRegisteredError

Thrown when a provider token is not found in the registry.

| Property     | Type      | Value                     |
| ------------ | --------- | ------------------------- |
| `code`       | `string`  | `PROVIDER_NOT_REGISTERED` |
| `statusCode` | `number`  | `500`                     |
| `isPublic`   | `boolean` | `false`                   |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ProviderNotRegisteredError(tokenName: string, context?: string)
```

**Example:**

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

throw new ProviderNotRegisteredError('DatabaseService', 'ToolRegistry');
// "Provider "DatabaseService" is not registered (ToolRegistry)"
```

***

### ProviderScopeMismatchError

Thrown when a provider's scope doesn't match the registry it's being resolved in.

| Property     | Type      | Value                     |
| ------------ | --------- | ------------------------- |
| `code`       | `string`  | `PROVIDER_SCOPE_MISMATCH` |
| `statusCode` | `number`  | `500`                     |
| `isPublic`   | `boolean` | `false`                   |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ProviderScopeMismatchError(tokenName: string, scopeName: string, registryName: string)
```

***

### ProviderNotInstantiatedError

Thrown when a provider is expected to be instantiated but hasn't been created yet.

| Property     | Type      | Value                       |
| ------------ | --------- | --------------------------- |
| `code`       | `string`  | `PROVIDER_NOT_INSTANTIATED` |
| `statusCode` | `number`  | `500`                       |
| `isPublic`   | `boolean` | `false`                     |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ProviderNotInstantiatedError(tokenName: string, scope?: string, context?: string)
```

***

### DependencyCycleError

Thrown when a circular dependency is detected in the provider graph.

| Property     | Type      | Value              |
| ------------ | --------- | ------------------ |
| `code`       | `string`  | `DEPENDENCY_CYCLE` |
| `statusCode` | `number`  | `500`              |
| `isPublic`   | `boolean` | `false`            |

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

**Example:**

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

throw new DependencyCycleError('A -> B -> C -> A');
// "Circular dependency detected: A -> B -> C -> A"
```

***

### ProviderConstructionError

Thrown when constructing a provider instance fails.

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

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ProviderConstructionError(tokenName: string, cause?: Error | string, qualifier?: string)
```

**Example:**

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

throw new ProviderConstructionError('DatabaseService', new Error('Connection refused'));
// "Failed to construct provider "DatabaseService": Connection refused"
```

***

### ProviderDependencyError

Thrown when a provider dependency cannot be resolved.

| Property     | Type      | Value                       |
| ------------ | --------- | --------------------------- |
| `code`       | `string`  | `PROVIDER_DEPENDENCY_ERROR` |
| `statusCode` | `number`  | `500`                       |
| `isPublic`   | `boolean` | `false`                     |

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

***

### ProviderScopedAccessError

Thrown when a scoped provider is accessed from the wrong scope.

| Property     | Type      | Value                    |
| ------------ | --------- | ------------------------ |
| `code`       | `string`  | `PROVIDER_SCOPED_ACCESS` |
| `statusCode` | `number`  | `500`                    |
| `isPublic`   | `boolean` | `false`                  |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ProviderScopedAccessError(tokenName: string, scopeName: string)
```

**Example:**

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

throw new ProviderScopedAccessError('RequestLogger', 'global');
// "Cannot access scoped provider "RequestLogger" from scope "global""
```

***

### ProviderNotAvailableError

Thrown when a provider is not available in the current context.

| Property     | Type      | Value                    |
| ------------ | --------- | ------------------------ |
| `code`       | `string`  | `PROVIDER_NOT_AVAILABLE` |
| `statusCode` | `number`  | `500`                    |
| `isPublic`   | `boolean` | `false`                  |

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
new ProviderNotAvailableError(tokenName: string, context?: string)
```

***

### PluginDependencyError

Thrown when a plugin dependency cannot be resolved.

| Property     | Type      | Value                     |
| ------------ | --------- | ------------------------- |
| `code`       | `string`  | `PLUGIN_DEPENDENCY_ERROR` |
| `statusCode` | `number`  | `500`                     |
| `isPublic`   | `boolean` | `false`                   |

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

***

### InvalidDependencyScopeError

Thrown when a dependency has an invalid scope configuration.

| Property     | Type      | Value                      |
| ------------ | --------- | -------------------------- |
| `code`       | `string`  | `INVALID_DEPENDENCY_SCOPE` |
| `statusCode` | `number`  | `500`                      |
| `isPublic`   | `boolean` | `false`                    |

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

***

### InvalidPluginScopeError

Thrown when a plugin with `scope='server'` is used in a standalone app, which is not allowed.

| Property     | Type      | Value                  |
| ------------ | --------- | ---------------------- |
| `code`       | `string`  | `INVALID_PLUGIN_SCOPE` |
| `statusCode` | `number`  | `500`                  |
| `isPublic`   | `boolean` | `false`                |

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