Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Clarify errors

Tomas Valenta406beb96d636
diff --git a/packages/js-sdk/src/connectionConfig.ts b/packages/js-sdk/src/connectionConfig.ts
index 4be35b513..264644d5d 100644
--- a/packages/js-sdk/src/connectionConfig.ts
+++ b/packages/js-sdk/src/connectionConfig.ts
@@ -1,3 +1,4 @@
+import { Code, ConnectError } from '@connectrpc/connect'
import { Logger } from './logs'
export const DOMAIN = process?.env?.E2B_DOMAIN || 'e2b.dev'
@@ -16,26 +17,70 @@ export interface ConnectionOpts {
logger?: Logger
}
-// function handleError(err: Error) {
-// if (err instanceof ConnectError) {
-// switch (err.code) {
-// case Code.InvalidArgument:
-// return new InvalidUserError(err.message)
-// case Code.NotFound:
-// return new InvalidPathError(err.message)
-// case Code.DeadlineExceeded:
-// return new TimeoutError(err.message)
-// case Code.Canceled:
-// return new TimeoutError(err.message)
-// default:
-// return new FilesystemError(err.message)
-// }
-// }
-// throw err
+export function handleApiError(err?: {
+ code: number;
+ message: string;
+} | undefined) {
+ if (!err) {
+ return
+ }
+
+ return new SandboxError(`${err.code}: ${err.message}`)
+}
+// This is the message for the sandbox timeout error when the response code is 502/Unavailable
+function formatSandboxTimeoutError(message: string) {
+ return new TimeoutError(
+ `${message}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.`,
+ )
+}
+
+export function handleEnvdApiError(err: {
+ code: number;
+ message: string;
+} | undefined) {
+ switch (err?.code) {
+ case 400:
+ return new InvalidUserError(err.message)
+ case 403:
+ return new InvalidPathError(err.message)
+ case 404:
+ return new NotFoundError(err.message)
+ case 502:
+ return formatSandboxTimeoutError(err.message)
+ case 507:
+ return new NotEnoughDiskSpaceError(err.message)
+ default:
+ if (err) {
+ return new SandboxError(`${err.code}: ${err.message}`)
+ }
+ }
+}
-// }
+export function handleRpcError(err: unknown) {
+ if (err instanceof ConnectError) {
+ switch (err.code) {
+ case Code.InvalidArgument:
+ return new InvalidUserError(err.message)
+ case Code.NotFound:
+ return new InvalidPathError(err.message)
+ case Code.Unavailable:
+ return formatSandboxTimeoutError(err.message)
+ case Code.Canceled:
+ return new TimeoutError(
+ `${err.message}: This error is likely due to exceeding 'requestTimeoutMs'. You can pass the request timeout value as an option when making the request.`,
+ )
+ case Code.DeadlineExceeded:
+ return new TimeoutError(
+ `${err.message}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout.`,
+ )
+ default:
+ return new SandboxError(`${err.code}: ${err.message}`)
+ }
+ }
+ return err
+}
export class SandboxError extends Error {
constructor(message: any) {
@@ -44,6 +89,8 @@ export class SandboxError extends Error {
}
}
+// [unknown] is sometimes caused by the sandbox timeout when the request is not processed
+// [unavailable] is caused by sandbox timeout
// [canceled] is caused by exceeding request timeout
// [deadline_exceeded] is caused by exceeding the timeout (for process handlers, watch, etc)
export class TimeoutError extends SandboxError {
@@ -56,7 +103,28 @@ export class TimeoutError extends SandboxError {
export class InvalidUserError extends SandboxError {
constructor(message: string) {
super(message)
- this.name = 'InvalidUsernameError'
+ this.name = 'InvalidUserError'
+ }
+}
+
+export class InvalidPathError extends SandboxError {
+ constructor(message: string) {
+ super(message)
+ this.name = 'InvalidPathError'
+ }
+}
+
+export class NotEnoughDiskSpaceError extends SandboxError {
+ constructor(message: string) {
+ super(message)
+ this.name = 'NotEnoughDiskSpaceError'
+ }
+}
+
+export class NotFoundError extends SandboxError {
+ constructor(message: string) {
+ super(message)
+ this.name = 'NotFoundError'
}
}
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.ts
index e812017e2..34bfb5989 100644
--- a/packages/js-sdk/src/index.ts
+++ b/packages/js-sdk/src/index.ts
@@ -4,7 +4,16 @@ export {
} from './api'
export type { components, paths } from './api'
-export { ConnectionConfig, SandboxError, DOMAIN, InvalidUserError } from './connectionConfig'
+export {
+ ConnectionConfig,
+ SandboxError,
+ DOMAIN,
+ InvalidUserError,
+ NotEnoughDiskSpaceError,
+ NotFoundError,
+ InvalidPathError,
+ TimeoutError,
+} from './connectionConfig'
export type { Logger } from './logs'
export type { ConnectionOpts, Username } from './connectionConfig'
@@ -13,10 +22,6 @@ export type {
EntryInfo,
} from './sandbox/filesystem'
export {
- NotEnoughDiskSpaceError,
- NotFoundError as FileNotFoundError,
- FilesystemError,
- InvalidPathError,
FileType,
} from './sandbox/filesystem'
diff --git a/packages/js-sdk/src/sandbox/filesystem/index.ts b/packages/js-sdk/src/sandbox/filesystem/index.ts
index af9d99a21..84b0871fa 100644
--- a/packages/js-sdk/src/sandbox/filesystem/index.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/index.ts
@@ -9,11 +9,11 @@ import {
import {
ConnectionConfig,
defaultUsername,
- SandboxError,
Username,
ConnectionOpts,
- TimeoutError,
- InvalidUserError,
+ handleRpcError,
+ handleEnvdApiError,
+ SandboxError,
} from '../../connectionConfig'
import { EnvdApiClient } from '../../envd/api'
import { Filesystem as FilesystemService } from '../../envd/filesystem/filesystem_connect'
@@ -41,34 +41,6 @@ export interface WatchOpts extends FilesystemRequestOpts {
onExit?: (err: Error) => void
}
-export class FilesystemError extends SandboxError {
- constructor(message: any) {
- super(message)
- this.name = 'FilesystemError'
- }
-}
-
-export class InvalidPathError extends FilesystemError {
- constructor(message: string) {
- super(message)
- this.name = 'InvalidPathError'
- }
-}
-
-export class NotEnoughDiskSpaceError extends FilesystemError {
- constructor(message: string) {
- super(message)
- this.name = 'NotEnoughDiskSpaceError'
- }
-}
-
-export class NotFoundError extends FilesystemError {
- constructor(message: string) {
- super(message)
- this.name = 'FileNotFoundError'
- }
-}
-
export class Filesystem {
private readonly rpc: PromiseClient<typeof FilesystemService>
private readonly envdApi: EnvdApiClient
@@ -90,30 +62,20 @@ export class Filesystem {
async read(path: string, opts?: FilesystemRequestOpts & { format?: 'text' | 'stream' | 'bytes' | 'blob' }): Promise<unknown> {
const format = opts?.format ?? 'text'
- const username = opts?.user || defaultUsername
-
const { data, error } = await this.envdApi.api.GET('/files', {
params: {
query: {
path,
- username,
+ username: opts?.user || defaultUsername,
},
},
parseAs: format === 'bytes' ? 'arrayBuffer' : format,
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
})
- switch (error?.code) {
- case 400:
- throw new InvalidUserError(error.message)
- case 403:
- throw new InvalidPathError(error.message)
- case 404:
- throw new NotFoundError(error.message)
- default:
- if (error) {
- throw new FilesystemError(error.message)
- }
+ const err = handleEnvdApiError(error)
+ if (err) {
+ throw err
}
if (format === 'bytes') {
@@ -126,13 +88,11 @@ export class Filesystem {
async write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<void> {
const blob = await new Response(data).blob()
- const username = opts?.user || defaultUsername
-
const { error } = await this.envdApi.api.POST('/files', {
params: {
query: {
path,
- username,
+ username: opts?.user || defaultUsername,
},
},
bodySerializer() {
@@ -146,30 +106,20 @@ export class Filesystem {
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
})
- switch (error?.code) {
- case 400:
- throw new InvalidUserError(error.message)
- case 403:
- throw new InvalidPathError(error.message)
- case 507:
- throw new NotEnoughDiskSpaceError(error.message)
- default:
- if (error) {
- throw new FilesystemError(error.message)
- }
+ const err = handleEnvdApiError(error)
+ if (err) {
+ throw err
}
}
async list(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo[]> {
- const username = opts?.user || defaultUsername
-
try {
const res = await this.rpc.listDir({
path,
user: {
selector: {
case: 'username',
- value: username,
+ value: opts?.user || defaultUsername,
},
},
}, {
@@ -181,33 +131,18 @@ export class Filesystem {
type: e.type === FsFileType.FILE ? FileType.FILE : FileType.DIR,
}))
} catch (err) {
- if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.InvalidArgument:
- throw new InvalidUserError(err.message)
- case Code.NotFound:
- throw new InvalidPathError(err.message)
- case Code.DeadlineExceeded:
- case Code.Canceled:
- throw new TimeoutError(err.message)
- default:
- throw new FilesystemError(err.message)
- }
- }
- throw err
+ throw handleRpcError(err)
}
}
async makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean> {
- const username = opts?.user || defaultUsername
-
try {
await this.rpc.makeDir({
path,
user: {
selector: {
case: 'username',
- value: username,
+ value: opts?.user || defaultUsername,
},
},
}, {
@@ -217,29 +152,16 @@ export class Filesystem {
return true
} catch (err) {
if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.InvalidArgument:
- throw new InvalidUserError(err.message)
- case Code.NotFound:
- throw new InvalidPathError(err.message)
- case Code.AlreadyExists:
- return false
- case Code.FailedPrecondition:
- throw new InvalidPathError(err.message)
- case Code.DeadlineExceeded:
- case Code.Canceled:
- throw new TimeoutError(err.message)
- default:
- throw new FilesystemError(err.message)
+ if (err.code === Code.AlreadyExists) {
+ return false
}
}
- throw err
+
+ throw handleRpcError(err)
}
}
async rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<boolean> {
- const username = opts?.user || defaultUsername
-
try {
await this.rpc.move({
source: oldPath,
@@ -247,7 +169,7 @@ export class Filesystem {
user: {
selector: {
case: 'username',
- value: username,
+ value: opts?.user || defaultUsername,
},
},
}, {
@@ -256,66 +178,36 @@ export class Filesystem {
return true
} catch (err) {
- if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.InvalidArgument:
- throw new InvalidUserError(err.message)
- case Code.NotFound:
- throw new InvalidPathError(err.message)
- case Code.DeadlineExceeded:
- case Code.Canceled:
- throw new TimeoutError(err.message)
- default:
- throw new FilesystemError(err.message)
- }
- }
- throw err
+ throw handleRpcError(err)
}
}
async remove(path: string, opts?: FilesystemRequestOpts): Promise<void> {
- const username = opts?.user || defaultUsername
-
try {
await this.rpc.remove({
path,
user: {
selector: {
case: 'username',
- value: username,
+ value: opts?.user || defaultUsername,
},
},
}, {
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
})
} catch (err) {
- if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.InvalidArgument:
- throw new InvalidUserError(err.message)
- case Code.NotFound:
- throw new InvalidPathError(err.message)
- case Code.DeadlineExceeded:
- case Code.Canceled:
- throw new TimeoutError(err.message)
- default:
- throw new FilesystemError(err.message)
- }
- }
- throw err
+ throw handleRpcError(err)
}
}
async exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean> {
- const username = opts?.user || defaultUsername
-
try {
await this.rpc.stat({
path,
user: {
selector: {
case: 'username',
- value: username,
+ value: opts?.user || defaultUsername,
},
},
}, {
@@ -325,19 +217,12 @@ export class Filesystem {
return true
} catch (err) {
if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.InvalidArgument:
- throw new InvalidUserError(err.message)
- case Code.NotFound:
- return false
- case Code.DeadlineExceeded:
- case Code.Canceled:
- throw new TimeoutError(err.message)
- default:
- throw new FilesystemError(err.message)
+ if (err.code === Code.NotFound) {
+ return false
}
}
- throw err
+
+ throw handleRpcError(err)
}
}
@@ -347,7 +232,6 @@ export class Filesystem {
opts?: FilesystemRequestOpts & { timeout?: number, onExit?: (err?: Error) => void | Promise<void> },
): Promise<WatchHandle> {
const requestTimeoutMs = opts?.requestTimeoutMs ?? this.connectionConfig.requestTimeoutMs
- const username = opts?.user || defaultUsername
const controller = new AbortController()
@@ -362,7 +246,7 @@ export class Filesystem {
user: {
selector: {
case: 'username',
- value: username,
+ value: opts?.user || defaultUsername,
},
},
}, {
@@ -374,32 +258,19 @@ export class Filesystem {
const startEvent: WatchDirResponse = (await events[Symbol.asyncIterator]().next()).value
if (startEvent.event.case !== 'start') {
- throw new Error('Expected start event')
- }
- } catch (err) {
- if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.InvalidArgument:
- throw new InvalidUserError(err.message)
- case Code.NotFound:
- throw new InvalidPathError(err.message)
- case Code.DeadlineExceeded:
- case Code.Canceled:
- throw new TimeoutError(err.message)
- default:
- throw new FilesystemError(err.message)
- }
+ throw new SandboxError('Expected start event')
}
- throw err
- }
- clearTimeout(reqTimeout)
+ clearTimeout(reqTimeout)
- return new WatchHandle(
- () => controller.abort(),
- events,
- onEvent,
- opts?.onExit,
- )
+ return new WatchHandle(
+ () => controller.abort(),
+ events,
+ onEvent,
+ opts?.onExit,
+ )
+ } catch (err) {
+ throw handleRpcError(err)
+ }
}
}
diff --git a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
index 26b7d40a4..bfec3ef57 100644
--- a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
@@ -1,7 +1,5 @@
-import { ConnectError, Code } from '@connectrpc/connect'
-import { FilesystemError } from '.'
-import { TimeoutError } from '../../connectionConfig'
+import { handleRpcError } from '../../connectionConfig'
import {
EventType,
WatchDirResponse,
@@ -61,21 +59,7 @@ export class WatchHandle {
}
}
} catch (err) {
- if (err instanceof ConnectError) {
- switch (err.code) {
- case Code.Canceled:
- throw new TimeoutError(
- `Error watching filesystem: ${err.message}. This is likely due to exceeding 'requestTimeoutMs' — that can be passed as options when watching filesystem. It can `,
- )
- case Code.DeadlineExceeded:
- throw new TimeoutError(
- `Error watching filesystem: ${err.message}. This is likely due to exceeding 'timeoutMs' — the total time the watching can be active. It can be modified by passing 'timeoutMs' to the watch function. Use '0' to disable the timeout.`,
- )
- default:
- throw new FilesystemError(err.message)
- }
- }
- throw err
+ throw handleRpcError(err)
} finally {
this.stop()
}
diff --git a/packages/js-sdk/src/sandbox/process/index.ts b/packages/js-sdk/src/sandbox/process/index.ts
index 63f3c9360..2be423b8b 100644
--- a/packages/js-sdk/src/sandbox/process/index.ts
+++ b/packages/js-sdk/src/sandbox/process/index.ts
@@ -3,7 +3,6 @@ import {
createPromiseClient,
PromiseClient,
Transport,
- ConnectError,
} from '@connectrpc/connect'
import { Process as ProcessService } from '../../envd/process/process_connect'
@@ -12,7 +11,7 @@ import {
Signal,
StartResponse,
} from '../../envd/process/process_pb'
-import { ConnectionConfig, defaultUsername, Username, ConnectionOpts, SandboxError } from '../../connectionConfig'
+import { ConnectionConfig, defaultUsername, Username, ConnectionOpts, SandboxError, handleRpcError } from '../../connectionConfig'
import { ProcessHandle, ProcessResult } from './processHandle'
export type ProcessInfo = PlainMessage<PsProcessInfo>
@@ -49,44 +48,56 @@ export class Process {
}
async list(opts?: ProcessRequestOpts): Promise<ProcessInfo[]> {
- const res = await this.rpc.list({}, {
- signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
- })
+ try {
+ const res = await this.rpc.list({}, {
+ signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
+ })
- return res.processes
+ return res.processes
+ } catch (err) {
+ throw handleRpcError(err)
+ }
}
async sendStdin(pid: number, data: string, opts?: ProcessRequestOpts): Promise<void> {
- await this.rpc.sendInput({
- process: {
- selector: {
- case: 'pid',
- value: pid,
- }
- },
- input: {
+ try {
+ await this.rpc.sendInput({
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ }
+ },
input: {
- case: 'stdin',
- value: new TextEncoder().encode(data),
+ input: {
+ case: 'stdin',
+ value: new TextEncoder().encode(data),
+ }
}
- }
- }, {
- signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
- })
+ }, {
+ signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
+ })
+ } catch (err) {
+ throw handleRpcError(err)
+ }
}
async kill(pid: number, opts?: ProcessRequestOpts): Promise<void> {
- await this.rpc.sendSignal({
- process: {
- selector: {
- case: 'pid',
- value: pid,
- }
- },
- signal: Signal.SIGKILL,
- }, {
- signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
- })
+ try {
+ await this.rpc.sendSignal({
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ }
+ },
+ signal: Signal.SIGKILL,
+ }, {
+ signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
+ })
+ } catch (err) {
+ throw handleRpcError(err)
+ }
}
async connect(pid: number, opts?: ProcessConnectOpts): Promise<ProcessHandle> {
@@ -112,17 +123,27 @@ export class Process {
timeoutMs: opts?.timeoutMs ?? 60_000,
})
- clearTimeout(reqTimeout)
-
- return new ProcessHandle(
- pid,
- () => controller.abort(),
- () => this.kill(pid),
- events,
- opts?.onStdout,
- opts?.onStderr,
- undefined,
- )
+ try {
+ const startEvent: StartResponse = (await events[Symbol.asyncIterator]().next()).value
+
+ if (startEvent.event?.event.case !== 'start') {
+ throw new SandboxError('Expected start event')
+ }
+
+ clearTimeout(reqTimeout)
+
+ return new ProcessHandle(
+ pid,
+ () => controller.abort(),
+ () => this.kill(pid),
+ events,
+ opts?.onStdout,
+ opts?.onStderr,
+ undefined,
+ )
+ } catch (err) {
+ throw handleRpcError(err)
+ }
}
async run(cmd: string, opts?: ProcessStartOpts & { background?: false }): Promise<ProcessResult>
@@ -146,29 +167,29 @@ export class Process {
}, requestTimeoutMs)
: undefined
- try {
- const events = this.rpc.start({
- user: {
- selector: {
- case: 'username',
- value: opts?.user || defaultUsername,
- },
- },
- process: {
- cmd: '/bin/bash',
- cwd: opts?.cwd,
- envs: opts?.envs,
- args: ['-l', '-c', cmd],
+ const events = this.rpc.start({
+ user: {
+ selector: {
+ case: 'username',
+ value: opts?.user || defaultUsername,
},
- }, {
- signal: controller.signal,
- timeoutMs: opts?.timeoutMs ?? 60_000,
- })
+ },
+ process: {
+ cmd: '/bin/bash',
+ cwd: opts?.cwd,
+ envs: opts?.envs,
+ args: ['-l', '-c', cmd],
+ },
+ }, {
+ signal: controller.signal,
+ timeoutMs: opts?.timeoutMs ?? 60_000,
+ })
+ try {
const startEvent: StartResponse = (await events[Symbol.asyncIterator]().next()).value
if (startEvent.event?.event.case !== 'start') {
- throw new Error('Expected start event')
+ throw new SandboxError('Expected start event')
}
clearTimeout(reqTimeout)
@@ -185,9 +206,7 @@ export class Process {
undefined,
)
} catch (err) {
- const connectErr = ConnectError.from(err)
- console.log(connectErr)
- throw err
+ throw handleRpcError(err)
}
}
}
diff --git a/packages/js-sdk/src/sandbox/process/processHandle.ts b/packages/js-sdk/src/sandbox/process/processHandle.ts
index 7254086f7..16a953a4a 100644
--- a/packages/js-sdk/src/sandbox/process/processHandle.ts
+++ b/packages/js-sdk/src/sandbox/process/processHandle.ts
@@ -1,3 +1,4 @@
+import { SandboxError } from '../../connectionConfig'
import {
ConnectResponse,
StartResponse,
@@ -140,7 +141,7 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
}
if (!this.result) {
- throw new ProcessError('Process exited without a result')
+ throw new SandboxError('Process exited without a result')
}
if (this.result.exitCode !== 0) {
diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts
index 8f422695f..d6b1010ac 100644
--- a/packages/js-sdk/src/sandbox/sandboxApi.ts
+++ b/packages/js-sdk/src/sandbox/sandboxApi.ts
@@ -1,5 +1,5 @@
import { ApiClient } from '../api'
-import { ConnectionConfig, ConnectionOpts } from '../connectionConfig'
+import { ConnectionConfig, ConnectionOpts, handleApiError } from '../connectionConfig'
export interface RunningSandbox {
sandboxID: string
@@ -19,13 +19,18 @@ export class SandboxApi {
const config = new ConnectionConfig(opts)
const client = new ApiClient(config)
- await client.api.DELETE('/sandboxes/{sandboxID}', {
+ const res = await client.api.DELETE('/sandboxes/{sandboxID}', {
params: {
path: {
sandboxID,
},
},
})
+
+ const err = handleApiError(res.error)
+ if (err) {
+ throw err
+ }
}
static async list(opts?: ConnectionOpts): Promise<RunningSandbox[]> {
@@ -34,6 +39,11 @@ export class SandboxApi {
const res = await client.api.GET('/sandboxes')
+ const err = handleApiError(res.error)
+ if (err) {
+ throw err
+ }
+
return res.data?.map((sandbox) => ({
sandboxID: this.getSandboxID(sandbox),
templateID: sandbox.templateID,
@@ -60,6 +70,11 @@ export class SandboxApi {
},
})
+ const err = handleApiError(res.error)
+ if (err) {
+ throw err
+ }
+
return this.getSandboxID(res.data!)
}
@@ -71,7 +86,7 @@ export class SandboxApi {
const config = new ConnectionConfig(opts)
const client = new ApiClient(config)
- await client.api.POST('/sandboxes/{sandboxID}/timeout', {
+ const res = await client.api.POST('/sandboxes/{sandboxID}/timeout', {
params: {
path: {
sandboxID,
@@ -81,6 +96,11 @@ export class SandboxApi {
timeout: this.timeoutToSeconds(timeoutMs),
},
})
+
+ const err = handleApiError(res.error)
+ if (err) {
+ throw err
+ }
}
private static timeoutToSeconds(timeout: number): number {