# Class: TunnelError

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

## Example[​](#example "Direct link to Example")

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

```

## Extends[​](#extends "Direct link to Extends")

* [`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md)

## Constructors[​](#constructors "Direct link to Constructors")

### Constructor[​](#constructor "Direct link to Constructor")

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

```

#### Parameters[​](#parameters "Direct link to Parameters")

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

#### Returns[​](#returns "Direct link to Returns")

`TunnelError`

#### Inherited from[​](#inherited-from "Direct link to Inherited from")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`constructor`](/appkit/docs/api/appkit/Class.AppKitError.md#constructor)

## Properties[​](#properties "Direct link to Properties")

### cause?[​](#cause "Direct link to cause?")

```ts
readonly optional cause: Error;

```

Optional cause of the error

#### Inherited from[​](#inherited-from-1 "Direct link to Inherited from")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`cause`](/appkit/docs/api/appkit/Class.AppKitError.md#cause)

***

### code[​](#code "Direct link to code")

```ts
readonly code: "TUNNEL_ERROR" = "TUNNEL_ERROR";

```

Error code for programmatic error handling

#### Overrides[​](#overrides "Direct link to Overrides")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`code`](/appkit/docs/api/appkit/Class.AppKitError.md#code)

***

### context?[​](#context "Direct link to context?")

```ts
readonly optional context: Record<string, unknown>;

```

Additional context for the error

#### Inherited from[​](#inherited-from-2 "Direct link to Inherited from")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`context`](/appkit/docs/api/appkit/Class.AppKitError.md#context)

***

### isRetryable[​](#isretryable "Direct link to isRetryable")

```ts
readonly isRetryable: true = true;

```

Whether this error type is generally safe to retry

#### Overrides[​](#overrides-1 "Direct link to Overrides")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`isRetryable`](/appkit/docs/api/appkit/Class.AppKitError.md#isretryable)

***

### statusCode[​](#statuscode "Direct link to statusCode")

```ts
readonly statusCode: 502 = 502;

```

HTTP status code suggestion (can be overridden)

#### Overrides[​](#overrides-2 "Direct link to Overrides")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`statusCode`](/appkit/docs/api/appkit/Class.AppKitError.md#statuscode)

## Methods[​](#methods "Direct link to Methods")

### toJSON()[​](#tojson "Direct link to toJSON()")

```ts
toJSON(): Record<string, unknown>;

```

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

#### Returns[​](#returns-1 "Direct link to Returns")

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

#### Inherited from[​](#inherited-from-3 "Direct link to Inherited from")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`toJSON`](/appkit/docs/api/appkit/Class.AppKitError.md#tojson)

***

### toString()[​](#tostring "Direct link to toString()")

```ts
toString(): string;

```

Create a human-readable string representation

#### Returns[​](#returns-2 "Direct link to Returns")

`string`

#### Inherited from[​](#inherited-from-4 "Direct link to Inherited from")

[`AppKitError`](/appkit/docs/api/appkit/Class.AppKitError.md).[`toString`](/appkit/docs/api/appkit/Class.AppKitError.md#tostring)

***

### fetchFailed()[​](#fetchfailed "Direct link to fetchFailed()")

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

```

Create a tunnel error for asset fetch failure

#### Parameters[​](#parameters-1 "Direct link to Parameters")

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

#### Returns[​](#returns-3 "Direct link to Returns")

`TunnelError`

***

### getterNotRegistered()[​](#getternotregistered "Direct link to getterNotRegistered()")

```ts
static getterNotRegistered(): TunnelError;

```

Create a tunnel error for missing tunnel getter

#### Returns[​](#returns-4 "Direct link to Returns")

`TunnelError`

***

### noConnection()[​](#noconnection "Direct link to noConnection()")

```ts
static noConnection(): TunnelError;

```

Create a tunnel error for no available connection

#### Returns[​](#returns-5 "Direct link to Returns")

`TunnelError`

***

### parseError()[​](#parseerror "Direct link to parseError()")

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

```

Create a tunnel error for message parsing failure

#### Parameters[​](#parameters-2 "Direct link to Parameters")

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

#### Returns[​](#returns-6 "Direct link to Returns")

`TunnelError`
