Skip to main content
⚠️ AppKit is in an early development phase and is subject to change without notice. DO NOT use in production environments.

# Class: TunnelError

Error thrown when remote tunnel operations fail. Use for tunnel connection issues, message parsing failures, etc.

## Example​

    throw new TunnelError("No tunnel connection available");
    throw new TunnelError("Failed to parse WebSocket message", { cause: parseError });

## Extends​

- `AppKitError`

## Constructors​

### Constructor​

    new TunnelError(message: string, options?: {
      cause?: Error;
      context?: Record<string, unknown>;
    }): TunnelError;

#### Parameters​

Parameter | Type
--- | ---
`message` | `string`
`options?` | { `cause?`: `Error`; `context?`: `Record`<`string`, `unknown`>; }
`options.cause?` | `Error`
`options.context?` | `Record`<`string`, `unknown`>

#### Returns​

`TunnelError`

#### Inherited from​

`AppKitError`.`constructor`

## Properties​

### cause?​

    readonly optional cause: Error;

Optional cause of the error

#### Inherited from​

`AppKitError`.`cause`

### code​

    readonly code: "TUNNEL_ERROR" = "TUNNEL_ERROR";

Error code for programmatic error handling

#### Overrides​

`AppKitError`.`code`

### context?​

    readonly optional context: Record<string, unknown>;

Additional context for the error

#### Inherited from​

`AppKitError`.`context`

### isRetryable​

    readonly isRetryable: true = true;

Whether this error type is generally safe to retry

#### Overrides​

`AppKitError`.`isRetryable`

### statusCode​

    readonly statusCode: 502 = 502;

HTTP status code suggestion (can be overridden)

#### Overrides​

`AppKitError`.`statusCode`

## Methods​

### toJSON()​

    toJSON(): Record<string, unknown>;

Convert error to JSON for logging/serialization. Sensitive values in context are automatically redacted.

#### Returns​

`Record`<`string`, `unknown`>

#### Inherited from​

`AppKitError`.`toJSON`

### toString()​

    toString(): string;

Create a human-readable string representation

#### Returns​

`string`

#### Inherited from​

`AppKitError`.`toString`

### fetchFailed()​

    static fetchFailed(path: string, cause?: Error): TunnelError;

Create a tunnel error for asset fetch failure

#### Parameters​

Parameter | Type
--- | ---
`path` | `string`
`cause?` | `Error`

#### Returns​

`TunnelError`

### getterNotRegistered()​

    static getterNotRegistered(): TunnelError;

Create a tunnel error for missing tunnel getter

#### Returns​

`TunnelError`

### noConnection()​

    static noConnection(): TunnelError;

Create a tunnel error for no available connection

#### Returns​

`TunnelError`

### parseError()​

    static parseError(messageType: string, cause?: Error): TunnelError;

Create a tunnel error for message parsing failure

#### Parameters​

Parameter | Type
--- | ---
`messageType` | `string`
`cause?` | `Error`

#### Returns​

`TunnelError`