---
title: "Errors"
hideTitleOnPage: true
---


## DaytonaAuthenticationError

Error thrown when authentication fails (HTTP 401).

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await daytona.list()
} catch (error) {
  if (error instanceof DaytonaAuthenticationError) {
    console.log(error.statusCode)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaAuthenticationError()

```ts
new DaytonaAuthenticationError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaAuthenticationError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaAuthenticationError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaAuthorizationError

Error thrown when the request is forbidden (HTTP 403).

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await daytona.get('sandbox-without-access')
} catch (error) {
  if (error instanceof DaytonaAuthorizationError) {
    console.log(error.message)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaAuthorizationError()

```ts
new DaytonaAuthorizationError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaAuthorizationError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaAuthorizationError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaConflictError

Error thrown when a resource conflict occurs (HTTP 409).

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await daytona.create({ name: 'existing-sandbox' })
} catch (error) {
  if (error instanceof DaytonaConflictError) {
    console.log(error.errorCode)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaConflictError()

```ts
new DaytonaConflictError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaConflictError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaConflictError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaConnectionError

Error thrown when a network connection fails.

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await ptyHandle.waitForConnection()
} catch (error) {
  if (error instanceof DaytonaConnectionError) {
    console.log(error.message)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaConnectionError()

```ts
new DaytonaConnectionError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaConnectionError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaConnectionError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaError

Base error for Daytona SDK.

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
- `headers?` _AxiosHeaders_ - Response headers if available
- `statusCode?` _number_ - HTTP status code if available
    




**Example:**

```ts
try {
  await daytona.get('missing-sandbox')
} catch (error) {
  if (error instanceof DaytonaError) {
    console.log(error.statusCode)
    console.log(error.errorCode)
    console.log(error.message)
  }
}
```

**Extends:**

- `Error`

### Extended by

- `DaytonaNotFoundError`
- `DaytonaRateLimitError`
- `DaytonaAuthenticationError`
- `DaytonaAuthorizationError`
- `DaytonaConflictError`
- `DaytonaValidationError`
- `DaytonaTimeoutError`
- `DaytonaConnectionError`

### Constructors

#### new DaytonaError()

```ts
new DaytonaError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaError`

##### Overrides

```ts
Error.constructor
```
## DaytonaNotFoundError

Error thrown when a resource is not found (HTTP 404).

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await sandbox.fs.downloadFile('/workspace/missing.txt')
} catch (error) {
  if (error instanceof DaytonaNotFoundError) {
    console.log(error.statusCode)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaNotFoundError()

```ts
new DaytonaNotFoundError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaNotFoundError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaNotFoundError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaRateLimitError

Error thrown when rate limit is exceeded.

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await daytona.list()
} catch (error) {
  if (error instanceof DaytonaRateLimitError) {
    console.log(error.errorCode)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaRateLimitError()

```ts
new DaytonaRateLimitError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaRateLimitError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaRateLimitError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaTimeoutError

Error thrown when a timeout occurs.

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  await sandbox.waitUntilStarted(1)
} catch (error) {
  if (error instanceof DaytonaTimeoutError) {
    console.log(error.message)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaTimeoutError()

```ts
new DaytonaTimeoutError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaTimeoutError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaTimeoutError`

##### Inherited from

`DaytonaError`.`constructor`
## DaytonaValidationError

Error thrown when input validation fails (HTTP 400 or client-side validation).

**Properties**:

- `errorCode?` _string_ - Machine-readable error code if available
    - _Inherited from_: `DaytonaError.errorCode`
- `headers?` _AxiosHeaders_ - Response headers if available
    - _Inherited from_: `DaytonaError.headers`
- `statusCode?` _number_ - HTTP status code if available
    
    - _Inherited from_: `DaytonaError.statusCode`




**Example:**

```ts
try {
  Image.debianSlim('3.8' as never)
} catch (error) {
  if (error instanceof DaytonaValidationError) {
    console.log(error.message)
  }
}
```

**Extends:**

- `DaytonaError`

### Constructors

#### new DaytonaValidationError()

```ts
new DaytonaValidationError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaValidationError
```

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaValidationError`

##### Inherited from

`DaytonaError`.`constructor`
## createAxiosDaytonaError()

```ts
function createAxiosDaytonaError(error: AxiosError): DaytonaError
```

Creates the appropriate Daytona error subclass from an Axios error.

**Parameters**:

- `error` _AxiosError_


**Returns**:

- `DaytonaError`

***


## createDaytonaError()

```ts
function createDaytonaError(
   message: string, 
   statusCode?: number, 
   headers?: AxiosHeaders, 
   errorCode?: string): DaytonaError
```

Creates the appropriate Daytona error subclass from structured error metadata.

**Parameters**:

- `message` _string_
- `statusCode?` _number_
- `headers?` _AxiosHeaders_
- `errorCode?` _string_


**Returns**:

- `DaytonaError`

***


## errorClassFromStatusCode()

```ts
function errorClassFromStatusCode(statusCode?: number): typeof DaytonaError
```

Maps an HTTP status code to the corresponding Daytona error class.

**Parameters**:

- `statusCode?` _number_


### Returns

*typeof* `DaytonaError`

***


## ResponseHeaders

```ts
type ResponseHeaders = InstanceType<typeof AxiosHeaders>;
```
