-
Notifications
You must be signed in to change notification settings - Fork 4
[SK-1851] Update Error Handling for Python SDK #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…th Client and Server Exception segregation
… ValidateToken Exceptions
There was a problem hiding this 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 modernizes error handling in the Scalekit Python SDK by replacing generic exceptions with structured error responses that include GRPC error codes, HTTP status codes, and detailed error information. The changes provide developers with more comprehensive error context to better handle and debug API failures.
Key changes:
- Replaced generic
Exception
instances with structuredScalekitException
classes - Added mapping between GRPC and HTTP status codes for consistent error handling
- Introduced specific exception types for different error scenarios (authentication, validation, server errors)
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
scalekit/common/exceptions.py | New exception hierarchy with structured error handling and status code mappings |
scalekit/core.py | Updated to use new exception classes instead of generic exceptions |
scalekit/client.py | Added specific token validation exception handling and moved webhook error class |
Comments suppressed due to low confidence (3)
scalekit/common/exceptions.py:88
- [nitpick] The method
error_code
should be a property to maintain consistency with other getters in the class likehttp_status
anderr_details
. It should be decorated with@property
.
def error_code(self):
scalekit/common/exceptions.py:118
- [nitpick] The method
error_code
should be a property to maintain consistency with other getters in the class likehttp_status
anderr_details
. It should be decorated with@property
.
def error_code(self):
scalekit/common/exceptions.py:216
- [nitpick] The method
error_code
should be a property to maintain consistency with other getters in the class likehttp_status
anderr_details
. It should be decorated with@property
.
def error_code(self):
bugbot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bugbot free trial expires on August 11, 2025
Learn more in the Cursor dashboard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[SK-1851] Update Error Handling for Python SDK
This PR is implemented to update error handling in the SDK methods. Compared to earlier version where we used to raise only error messages as part of the exceptions, here we are providing customer with an error response that conrains GRPC error codes, HTTP error codes and error details.
The Error returned by this change would be displayed as below example,
Example 1:
ScalekitServerException - Inheriting ScalekitException
- grpc_status (<StatusCode.INVALID_ARGUMENT: (3, 'invalid argument')>)
- http_status (<HTTPStatus.BAD_REQUEST: 400>)
- err_details (['Validation error', 'user.email: value must be a valid email address'])
- error_code 'INVALID_ARGUMENT'
_- message 'Validation error'