Skip to content

sandbox: Add error hierarchy#67

Open
scotttrinh wants to merge 1 commit intomainfrom
sandbox/better-error-hierarchy
Open

sandbox: Add error hierarchy#67
scotttrinh wants to merge 1 commit intomainfrom
sandbox/better-error-hierarchy

Conversation

@scotttrinh
Copy link
Collaborator

Add specific error classes to help downstream consumers to do conditional error handling and bring structure to our generic APIError class.

Add specific error classes to help downstream consumers to do
conditional error handling and bring structure to our generic APIError
class.
@vercel
Copy link

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vercel-py Ready Ready Preview Mar 24, 2026 3:00pm

Request Review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a structured sandbox-specific error hierarchy so downstream consumers can perform conditional error handling (e.g., auth vs rate-limit vs server failures) while preserving the existing APIError surface.

Changes:

  • Add SandboxError as a base class and introduce sandbox-specific APIError subclasses (SandboxAuthError, SandboxPermissionError, SandboxRateLimitError, SandboxServerError).
  • Update SandboxRequestClient to classify non-2xx HTTP responses into the new typed errors (including retry_after support for 429s).
  • Re-export the new error types from both internal and public sandbox modules and expand unit/integration test coverage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/test_sandbox_errors.py Adds unit tests covering public re-exports and status-code-based error classification.
tests/integration/test_sandbox_streaming_errors.py Updates streaming integration tests to assert the new typed errors for non-2xx responses.
src/vercel/sandbox/init.py Re-exports the new public error hierarchy from the sandbox package.
src/vercel/_internal/sandbox/errors.py Defines the new sandbox error hierarchy and retry_after normalization for rate limits.
src/vercel/_internal/sandbox/core.py Implements status-code-to-exception mapping and raises typed sandbox errors from the request layer.
src/vercel/_internal/sandbox/init.py Re-exports internal error types to support public imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants