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: ConnectionError

Error thrown when a connection or network operation fails. Use for database pool errors, API failures, timeouts, etc.

## Example​

    throw new ConnectionError("Query failed", { cause: pgError });
    throw new ConnectionError("No response received from SQL Warehouse API");

## Extends​

- `AppKitError`

## Constructors​

### Constructor​

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

#### Parameters​

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

#### Returns​

`ConnectionError`

#### Inherited from​

`AppKitError`.`constructor`

## Properties​

### cause?​

    readonly optional cause: Error;

Optional cause of the error

#### Inherited from​

`AppKitError`.`cause`

### code​

    readonly code: "CONNECTION_ERROR" = "CONNECTION_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: 503 = 503;

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`

### apiFailure()​

    static apiFailure(service: string, cause?: Error): ConnectionError;

Create a connection error for API failures

#### Parameters​

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

#### Returns​

`ConnectionError`

### clientUnavailable()​

    static clientUnavailable(clientType: string, hint?: string): ConnectionError;

Create a connection error for client unavailable

#### Parameters​

Parameter | Type
--- | ---
`clientType` | `string`
`hint?` | `string`

#### Returns​

`ConnectionError`

### poolError()​

    static poolError(operation: string, cause?: Error): ConnectionError;

Create a connection error for pool errors

#### Parameters​

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

#### Returns​

`ConnectionError`

### queryFailed()​

    static queryFailed(cause?: Error): ConnectionError;

Create a connection error for query failure

#### Parameters​

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

#### Returns​

`ConnectionError`

### transactionFailed()​

    static transactionFailed(cause?: Error): ConnectionError;

Create a connection error for transaction failure

#### Parameters​

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

#### Returns​

`ConnectionError`