Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Move template exceptions to shared (#953)
Mish Ushakov1d0d404dc0f8
diff --git a/.changeset/friendly-news-whisper.md b/.changeset/friendly-news-whisper.mdnew file mode 100644index 000000000..cd6c80714--- /dev/null+++ b/.changeset/friendly-news-whisper.md@@ -0,0 +1,6 @@+---+'@e2b/python-sdk': patch+'e2b': patch+---++moved template exceptions to commondiff --git a/packages/js-sdk/src/errors.ts b/packages/js-sdk/src/errors.tsindex 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.tsindex 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.tsindex 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.tsdeleted file mode 100644index 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__.pyindex 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 CommandHandlefrom .sandbox_sync.filesystem.watch_handle import WatchHandlefrom .sandbox_sync.main import Sandboxfrom .sandbox_sync.paginator import SandboxPaginator-from .template.exceptions import BuildException, FileUploadExceptionfrom .template.logger import (LogEntry,LogEntryLevel,diff --git a/packages/python-sdk/e2b/exceptions.py b/packages/python-sdk/e2b/exceptions.pyindex 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.pydeleted file mode 100644index 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.pyindex 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, FileUploadExceptionfrom e2b.template.logger import LogEntryfrom e2b.template.types import TemplateTypefrom e2b.template.utils import get_build_step_indexdiff --git a/packages/python-sdk/e2b/template_sync/build_api.py b/packages/python-sdk/e2b/template_sync/build_api.pyindex 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, FileUploadExceptionfrom e2b.template.logger import LogEntryfrom e2b.template.types import TemplateTypefrom e2b.template.utils import get_build_step_index