Skip to content

feat: add BlaxelAPIError base exception for unified error handling#138

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1777574827-unified-blaxel-api-error
Open

feat: add BlaxelAPIError base exception for unified error handling#138
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1777574827-unified-blaxel-api-error

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 30, 2026

Summary

Introduces a common BlaxelAPIError base exception so users can catch all Blaxel API errors with a single except clause:

from blaxel.core import BlaxelAPIError

try:
    sandbox = await SandboxInstance.create(...)
except BlaxelAPIError as e:
    print(e.status_code, e.error_code)

Changes

  • BlaxelAPIError base class in src/blaxel/core/client/errors.py with status_code, error_code, and response fields.
  • UnexpectedStatus now extends BlaxelAPIError (maps status_code).
  • SandboxAPIError now extends BlaxelAPIError (maps codeerror_code).
  • DriveAPIError now extends BlaxelAPIError (maps codeerror_code).
  • VolumeAPIError now extends BlaxelAPIError (maps codeerror_code).
  • ResponseError now extends BlaxelAPIError (extracts status_code from response).
  • error_to_exception() utility function to convert the auto-generated Error data model to a BlaxelAPIError (avoids editing generated code).
  • Both BlaxelAPIError and error_to_exception are exported from blaxel.core.

Backward compatibility

All existing subclass names and signatures are preserved. The only change is their parent class (ExceptionBlaxelAPIErrorException), so existing except SandboxAPIError etc. still work.

Review & Testing Checklist for Human

  • Verify except BlaxelAPIError catches SandboxAPIError, DriveAPIError, VolumeAPIError, UnexpectedStatus, and ResponseError as expected
  • Confirm subclass code attribute is still accessible (backward compat) alongside the new error_code on the base
  • Run integration tests (uv run pytest tests/integration/ -v -s) to validate no regressions

Notes

  • The Error data model in client/models/error.py is auto-generated and was not modified. Instead, a free function error_to_exception() converts it to a BlaxelAPIError.
  • The sandbox client's UnexpectedStatus (sandbox/client/errors.py) is also auto-generated and was left unchanged.

Link to Devin session: https://app.devin.ai/sessions/7413077191c34b82b10658a946cc1918
Requested by: @Joffref


Note

Introduces BlaxelAPIError as a common base exception for all Blaxel API error types (UnexpectedStatus, SandboxAPIError, DriveAPIError, VolumeAPIError, ResponseError), plus an error_to_exception() utility to convert the auto-generated Error model. Both are exported from blaxel.core.

Written by Mendral for commit 62a3e67.

- Create BlaxelAPIError base class in client/errors.py
- Make UnexpectedStatus extend BlaxelAPIError
- Make SandboxAPIError, DriveAPIError, VolumeAPIError extend BlaxelAPIError
- Make ResponseError extend BlaxelAPIError
- Add error_to_exception() utility to convert Error data model
- Export BlaxelAPIError and error_to_exception from blaxel.core

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor

@mendral-app mendral-app Bot left a comment

Choose a reason for hiding this comment

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

LGTM

Clean, focused change with no security issues, correctness bugs, or data loss risks. Backward compatibility is preserved — subclass code attributes are retained and existing except SandboxAPIError etc. still work. The error_to_exception() message fallback (error.messageerror.error) is correct given error.error is a required str field.

Tag @mendral-app with feedback or questions. View session

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.

1 participant