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

Error thrown when server lifecycle operations fail. Use for server start/stop issues, configuration conflicts, etc.

## Example​

    throw new ServerError("Cannot get server when autoStart is true");
    throw new ServerError("Server not started");

## Extends​

- `AppKitError`

## Constructors​

### Constructor​

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

#### Parameters​

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

#### Returns​

`ServerError`

#### Inherited from​

`AppKitError`.`constructor`

## Properties​

### cause?​

    readonly optional cause: Error;

Optional cause of the error

#### Inherited from​

`AppKitError`.`cause`

### code​

    readonly code: "SERVER_ERROR" = "SERVER_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: false = false;

Whether this error type is generally safe to retry

#### Overrides​

`AppKitError`.`isRetryable`

### statusCode​

    readonly statusCode: 500 = 500;

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`

### autoStartConflict()​

    static autoStartConflict(operation: string): ServerError;

Create a server error for autoStart conflict

#### Parameters​

Parameter | Type
--- | ---
`operation` | `string`

#### Returns​

`ServerError`

### clientDirectoryNotFound()​

    static clientDirectoryNotFound(searchedPaths: string[]): ServerError;

Create a server error for missing client directory

#### Parameters​

Parameter | Type
--- | ---
`searchedPaths` | `string`[]

#### Returns​

`ServerError`

### notStarted()​

    static notStarted(): ServerError;

Create a server error for server not started

#### Returns​

`ServerError`

### viteNotInitialized()​

    static viteNotInitialized(): ServerError;

Create a server error for Vite dev server not initialized

#### Returns​

`ServerError`