# Class: ServerError

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

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

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

```

## 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 ServerError(message: string, options?: {
  cause?: Error;
  context?: Record<string, unknown>;
}): ServerError;

```

#### 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")

`ServerError`

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

```

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: 500 = 500;

```

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)

***

### autoStartConflict()[​](#autostartconflict "Direct link to autoStartConflict()")

```ts
static autoStartConflict(operation: string): ServerError;

```

Create a server error for autoStart conflict

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

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

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

`ServerError`

***

### clientDirectoryNotFound()[​](#clientdirectorynotfound "Direct link to clientDirectoryNotFound()")

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

```

Create a server error for missing client directory

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

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

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

`ServerError`

***

### notStarted()[​](#notstarted "Direct link to notStarted()")

```ts
static notStarted(): ServerError;

```

Create a server error for server not started

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

`ServerError`

***

### viteNotInitialized()[​](#vitenotinitialized "Direct link to viteNotInitialized()")

```ts
static viteNotInitialized(): ServerError;

```

Create a server error for Vite dev server not initialized

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

`ServerError`
