Skip to content

Commit 6b73a27

Browse files
committed
Return NotFoundError/Exception for get info and set timeout, instead of generic error
1 parent 263f680 commit 6b73a27

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

packages/js-sdk/src/sandbox/sandboxApi.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ export class SandboxApi {
357357
signal: config.getSignal(opts?.requestTimeoutMs),
358358
})
359359

360+
if (res.error?.code === 404) {
361+
throw new NotFoundError(`Sandbox ${sandboxId} not found`)
362+
}
363+
360364
const err = handleApiError(res)
361365
if (err) {
362366
throw err
@@ -376,6 +380,10 @@ export class SandboxApi {
376380
signal: config.getSignal(opts?.requestTimeoutMs),
377381
})
378382

383+
if (res.error?.code === 404) {
384+
throw new NotFoundError(`Sandbox ${sandboxId} not found`)
385+
}
386+
379387
const err = handleApiError(res)
380388
if (err) {
381389
throw err

packages/python-sdk/e2b/sandbox_async/sandbox_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ async def _cls_get_info(
7676
client=api_client,
7777
)
7878

79+
if res.status_code == 404:
80+
raise NotFoundException(f"Sandbox {sandbox_id} not found")
81+
7982
if res.status_code >= 300:
8083
raise handle_api_exception(res)
8184

@@ -139,6 +142,9 @@ async def _cls_set_timeout(
139142
body=PostSandboxesSandboxIDTimeoutBody(timeout=timeout),
140143
)
141144

145+
if res.status_code == 404:
146+
raise NotFoundException(f"Paused sandbox {sandbox_id} not found")
147+
142148
if res.status_code >= 300:
143149
raise handle_api_exception(res)
144150

packages/python-sdk/e2b/sandbox_sync/sandbox_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def _cls_get_info(
7575
client=api_client,
7676
)
7777

78+
if res.status_code == 404:
79+
raise NotFoundException(f"Sandbox {sandbox_id} not found")
80+
7881
if res.status_code >= 300:
7982
raise handle_api_exception(res)
8083

@@ -138,6 +141,9 @@ def _cls_set_timeout(
138141
body=PostSandboxesSandboxIDTimeoutBody(timeout=timeout),
139142
)
140143

144+
if res.status_code == 404:
145+
raise NotFoundException(f"Sandbox {sandbox_id} not found")
146+
141147
if res.status_code >= 300:
142148
raise handle_api_exception(res)
143149

0 commit comments

Comments
 (0)