Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Move template exceptions to shared (#953)

Mish Ushakov1d0d404dc0f8
diff --git a/.changeset/friendly-news-whisper.md b/.changeset/friendly-news-whisper.md
new file mode 100644
index 000000000..cd6c80714
--- /dev/null
+++ b/.changeset/friendly-news-whisper.md
@@ -0,0 +1,6 @@
+---
+'@e2b/python-sdk': patch
+'e2b': patch
+---
+
+moved template exceptions to common
diff --git a/packages/js-sdk/src/errors.ts b/packages/js-sdk/src/errors.ts
index 7c226b8a5..1e3eb6ebf 100644
--- a/packages/js-sdk/src/errors.ts
+++ b/packages/js-sdk/src/errors.ts
@@ -97,3 +97,26 @@ export class RateLimitError extends SandboxError {
this.name = 'RateLimitError'
}
}
+
+/**
+ * Thrown when the build fails.
+ */
+export class BuildError extends Error {
+ constructor(message: string, stackTrace?: string) {
+ super(message)
+ this.name = 'BuildError'
+ if (stackTrace) {
+ this.stack = stackTrace
+ }
+ }
+}
+
+/**
+ * Thrown when the file upload fails.
+ */
+export class FileUploadError extends BuildError {
+ constructor(message: string, stackTrace?: string) {
+ super(message, stackTrace)
+ this.name = 'FileUploadError'
+ }
+}
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.ts
index 393c04c1b..7db33da5a 100644
--- a/packages/js-sdk/src/index.ts
+++ b/packages/js-sdk/src/index.ts
@@ -12,6 +12,8 @@ export {
TemplateError,
TimeoutError,
RateLimitError,
+ BuildError,
+ FileUploadError,
} from './errors'
export type { Logger } from './logs'
@@ -62,8 +64,6 @@ import { Sandbox } from './sandbox'
export default Sandbox
-export { BuildError, FileUploadError } from './template/errors'
-
export type {
BuildOptions,
CopyItem,
diff --git a/packages/js-sdk/src/template/buildApi.ts b/packages/js-sdk/src/template/buildApi.ts
index 9369a68b5..4607a9a76 100644
--- a/packages/js-sdk/src/template/buildApi.ts
+++ b/packages/js-sdk/src/template/buildApi.ts
@@ -1,6 +1,6 @@
import { ApiClient, handleApiError, paths } from '../api'
import { stripAnsi } from '../utils'
-import { BuildError, FileUploadError } from './errors'
+import { BuildError, FileUploadError } from '../errors'
import { LogEntry } from './logger'
import { getBuildStepIndex, tarFileStreamUpload } from './utils'
diff --git a/packages/js-sdk/src/template/errors.ts b/packages/js-sdk/src/template/errors.ts
deleted file mode 100644
index ef221997c..000000000
--- a/packages/js-sdk/src/template/errors.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Thrown when the build fails.
- */
-export class BuildError extends Error {
- constructor(message: string, stackTrace?: string) {
- super(message)
- this.name = 'BuildError'
- if (stackTrace) {
- this.stack = stackTrace
- }
- }
-}
-
-/**
- * Thrown when the file upload fails.
- */
-export class FileUploadError extends BuildError {
- constructor(message: string, stackTrace?: string) {
- super(message, stackTrace)
- this.name = 'FileUploadError'
- }
-}
diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.py
index 922643188..12f152bc4 100644
--- a/packages/python-sdk/e2b/__init__.py
+++ b/packages/python-sdk/e2b/__init__.py
@@ -41,6 +41,8 @@ from .exceptions import (
InvalidArgumentException,
NotEnoughSpaceException,
TemplateException,
+ BuildException,
+ FileUploadException,
)
from .sandbox.commands.command_handle import (
CommandResult,
@@ -67,7 +69,6 @@ from .sandbox_sync.commands.command_handle import CommandHandle
from .sandbox_sync.filesystem.watch_handle import WatchHandle
from .sandbox_sync.main import Sandbox
from .sandbox_sync.paginator import SandboxPaginator
-from .template.exceptions import BuildException, FileUploadException
from .template.logger import (
LogEntry,
LogEntryLevel,
diff --git a/packages/python-sdk/e2b/exceptions.py b/packages/python-sdk/e2b/exceptions.py
index 9f95218a8..ec75a99bb 100644
--- a/packages/python-sdk/e2b/exceptions.py
+++ b/packages/python-sdk/e2b/exceptions.py
@@ -81,3 +81,15 @@ class RateLimitException(SandboxException):
"""
Raised when the API rate limit is exceeded.
"""
+
+
+class BuildException(Exception):
+ """
+ Raised when the build fails.
+ """
+
+
+class FileUploadException(BuildException):
+ """
+ Raised when the file upload fails.
+ """
diff --git a/packages/python-sdk/e2b/template/exceptions.py b/packages/python-sdk/e2b/template/exceptions.py
deleted file mode 100644
index ef6bcddb5..000000000
--- a/packages/python-sdk/e2b/template/exceptions.py
+++ /dev/null
@@ -1,10 +0,0 @@
-class BuildException(Exception):
- """
- Raised when the build fails.
- """
-
-
-class FileUploadException(BuildException):
- """
- Raised when the file upload fails.
- """
diff --git a/packages/python-sdk/e2b/template_async/build_api.py b/packages/python-sdk/e2b/template_async/build_api.py
index 38eace670..103e8f895 100644
--- a/packages/python-sdk/e2b/template_async/build_api.py
+++ b/packages/python-sdk/e2b/template_async/build_api.py
@@ -23,7 +23,7 @@ from e2b.api.client.models import (
TemplateBuild,
Error,
)
-from e2b.template.exceptions import BuildException, FileUploadException
+from e2b.exceptions import BuildException, FileUploadException
from e2b.template.logger import LogEntry
from e2b.template.types import TemplateType
from e2b.template.utils import get_build_step_index
diff --git a/packages/python-sdk/e2b/template_sync/build_api.py b/packages/python-sdk/e2b/template_sync/build_api.py
index 51fd4de28..30959c06a 100644
--- a/packages/python-sdk/e2b/template_sync/build_api.py
+++ b/packages/python-sdk/e2b/template_sync/build_api.py
@@ -23,7 +23,7 @@ from e2b.api.client.models import (
TemplateBuild,
Error,
)
-from e2b.template.exceptions import BuildException, FileUploadException
+from e2b.exceptions import BuildException, FileUploadException
from e2b.template.logger import LogEntry
from e2b.template.types import TemplateType
from e2b.template.utils import get_build_step_index