Skip to content

Commit 6b4d4b9

Browse files
committed
Cleanup
1 parent 1287fbb commit 6b4d4b9

File tree

4 files changed

+15
-30
lines changed

4 files changed

+15
-30
lines changed

packages/js-sdk/src/api/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import createClient, { FetchResponse } from 'openapi-fetch'
33
import type { components, paths } from './schema.gen'
44
import { defaultHeaders } from './metadata'
55
import { ConnectionConfig } from '../connectionConfig'
6-
import { AuthenticationError, RateLimitError, SandboxError, NotFoundError } from '../errors'
6+
import {
7+
AuthenticationError,
8+
RateLimitError,
9+
SandboxError,
10+
NotFoundError,
11+
} from '../errors'
712
import { createApiLogger } from '../logs'
813

914
export function handleApiError(
@@ -61,15 +66,15 @@ class ApiClient {
6166
if (opts?.requireApiKey && !config.apiKey) {
6267
throw new AuthenticationError(
6368
'API key is required, please visit the Team tab at https://e2b.dev/dashboard to get your API key. ' +
64-
'You can either set the environment variable `E2B_API_KEY` ' +
65-
"or you can pass it directly to the sandbox like Sandbox.create({ apiKey: 'e2b_...' })"
69+
'You can either set the environment variable `E2B_API_KEY` ' +
70+
"or you can pass it directly to the sandbox like Sandbox.create({ apiKey: 'e2b_...' })"
6671
)
6772
}
6873

6974
if (opts?.requireAccessToken && !config.accessToken) {
7075
throw new AuthenticationError(
7176
'Access token is required, please visit the Personal tab at https://e2b.dev/dashboard to get your access token. ' +
72-
'You can set the environment variable `E2B_ACCESS_TOKEN` or pass the `accessToken` in options.'
77+
'You can set the environment variable `E2B_ACCESS_TOKEN` or pass the `accessToken` in options.'
7378
)
7479
}
7580

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DEFAULT_SANDBOX_TIMEOUT_MS,
66
} from '../connectionConfig'
77
import { compareVersions } from 'compare-versions'
8-
import { NotFoundError, TemplateError } from '../errors'
8+
import { TemplateError } from '../errors'
99
import { timeoutToSeconds } from '../utils'
1010
import type { McpServer } from './mcp'
1111

@@ -18,7 +18,7 @@ export interface SandboxApiOpts
1818
ConnectionOpts,
1919
'apiKey' | 'headers' | 'debug' | 'domain' | 'requestTimeoutMs'
2020
>
21-
> { }
21+
> {}
2222

2323
/**
2424
* Options for creating a new Sandbox.
@@ -224,7 +224,7 @@ export interface SandboxMetrics {
224224
}
225225

226226
export class SandboxApi {
227-
protected constructor() { }
227+
protected constructor() {}
228228

229229
/**
230230
* Kill the sandbox specified by sandbox ID.
@@ -425,10 +425,6 @@ export class SandboxApi {
425425
signal: config.getSignal(opts?.requestTimeoutMs),
426426
})
427427

428-
if (res.error?.code === 404) {
429-
throw new NotFoundError(`Sandbox ${sandboxId} not found`)
430-
}
431-
432428
if (res.error?.code === 409) {
433429
// Sandbox is already paused
434430
return false
@@ -477,7 +473,7 @@ export class SandboxApi {
477473
await this.kill(res.data!.sandboxID, opts)
478474
throw new TemplateError(
479475
'You need to update the template to use the new SDK. ' +
480-
'You can do this by running `e2b template build` in the directory with the template.'
476+
'You can do this by running `e2b template build` in the directory with the template.'
481477
)
482478
}
483479

@@ -510,10 +506,6 @@ export class SandboxApi {
510506
signal: config.getSignal(opts?.requestTimeoutMs),
511507
})
512508

513-
if (res.error?.code === 404) {
514-
throw new NotFoundError(`Paused sandbox ${sandboxId} not found`)
515-
}
516-
517509
if (res.error?.code === 409) {
518510
// Sandbox is already running
519511
return false

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from e2b.api.client.types import UNSET
88
from e2b.sandbox.main import SandboxBase
99
from e2b.sandbox.sandbox_api import SandboxInfo, SandboxMetrics, SandboxQuery
10-
from e2b.exceptions import TemplateException, SandboxException, NotFoundException
10+
from e2b.exceptions import TemplateException, SandboxException
1111
from e2b.api import AsyncApiClient, SandboxCreateResponse
1212
from e2b.api.client.models import (
1313
NewSandbox,
@@ -271,9 +271,6 @@ async def _cls_pause(
271271
client=api_client,
272272
)
273273

274-
if res.status_code == 404:
275-
raise NotFoundException(f"Sandbox {sandbox_id} not found")
276-
277274
if res.status_code == 409:
278275
return sandbox_id
279276

@@ -319,9 +316,6 @@ async def _cls_resume(
319316
body=ResumedSandbox(timeout=timeout),
320317
)
321318

322-
if res.status_code == 404:
323-
raise NotFoundException(f"Paused sandbox {sandbox_id} not found")
324-
325319
if res.status_code == 409:
326320
return False
327321

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from e2b.sandbox.sandbox_api import SandboxInfo, SandboxMetrics, SandboxQuery
88
from e2b.sandbox.main import SandboxBase
9-
from e2b.exceptions import TemplateException, SandboxException, NotFoundException
9+
from e2b.exceptions import TemplateException, SandboxException
1010
from e2b.api import ApiClient, SandboxCreateResponse
1111
from e2b.api.client.models import (
1212
NewSandbox,
@@ -277,9 +277,6 @@ def _cls_resume(
277277
body=ResumedSandbox(timeout=timeout),
278278
)
279279

280-
if res.status_code == 404:
281-
raise NotFoundException(f"Paused sandbox {sandbox_id} not found")
282-
283280
if res.status_code == 409:
284281
return False
285282

@@ -305,9 +302,6 @@ def _cls_pause(
305302
client=api_client,
306303
)
307304

308-
if res.status_code == 404:
309-
raise NotFoundException(f"Sandbox {sandbox_id} not found")
310-
311305
if res.status_code == 409:
312306
return sandbox_id
313307

0 commit comments

Comments
 (0)