Skip to content
View as Markdown

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:

try {
for await (const sandbox of daytona.list()) {
console.log(sandbox.id)
}
} catch (error) {
if (error instanceof DaytonaAuthenticationError) {
console.log(error.statusCode)
}
}

Extends:

  • DaytonaError
new DaytonaAuthenticationError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaAuthenticationError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaAuthenticationError

DaytonaError.constructor

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:

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

Extends:

  • DaytonaError
new DaytonaAuthorizationError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaAuthorizationError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaAuthorizationError

DaytonaError.constructor

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:

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

Extends:

  • DaytonaError
new DaytonaConflictError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaConflictError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaConflictError

DaytonaError.constructor

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:

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

Extends:

  • DaytonaError
new DaytonaConnectionError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaConnectionError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaConnectionError

DaytonaError.constructor

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:

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
  • DaytonaNotFoundError
  • DaytonaRateLimitError
  • DaytonaAuthenticationError
  • DaytonaAuthorizationError
  • DaytonaConflictError
  • DaytonaValidationError
  • DaytonaTimeoutError
  • DaytonaConnectionError
new DaytonaError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaError
Error.constructor

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:

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

Extends:

  • DaytonaError
new DaytonaNotFoundError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaNotFoundError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaNotFoundError

DaytonaError.constructor

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:

try {
for await (const sandbox of daytona.list()) {
console.log(sandbox.id)
}
} catch (error) {
if (error instanceof DaytonaRateLimitError) {
console.log(error.errorCode)
}
}

Extends:

  • DaytonaError
new DaytonaRateLimitError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaRateLimitError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaRateLimitError

DaytonaError.constructor

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:

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

Extends:

  • DaytonaError
new DaytonaTimeoutError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaTimeoutError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaTimeoutError

DaytonaError.constructor

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:

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

Extends:

  • DaytonaError
new DaytonaValidationError(
message: string,
statusCode?: number,
headers?: AxiosHeaders,
errorCode?: string): DaytonaValidationError

Parameters:

  • message string
  • statusCode? number
  • headers? AxiosHeaders
  • errorCode? string

Returns:

  • DaytonaValidationError

DaytonaError.constructor

function createAxiosDaytonaError(error: AxiosError): DaytonaError

Creates the appropriate Daytona error subclass from an Axios error.

Parameters:

  • error AxiosError

Returns:

  • DaytonaError

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

function errorClassFromStatusCode(statusCode?: number): typeof DaytonaError

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

Parameters:

  • statusCode? number

typeof DaytonaError


type ResponseHeaders = InstanceType<typeof AxiosHeaders>;