-
Notifications
You must be signed in to change notification settings - Fork 455
refactor(event_handler): allow to pass dict as argument to exception classes #7341
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
refactor(event_handler): allow to pass dict as argument to exception classes #7341
Conversation
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7341 +/- ##
===========================================
- Coverage 96.36% 96.33% -0.04%
===========================================
Files 275 275
Lines 13002 13003 +1
Branches 966 966
===========================================
- Hits 12529 12526 -3
- Misses 366 368 +2
- Partials 107 109 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Thanks for working on this @shrivarshapoojari! APPROVED.
|
Codecov is reporting indirect changes that are not part of this PR! It's safe to merge. |
a186759
into
aws-powertools:develop
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |



Issue number: closes #7279
Summary
This PR enhances event handler exception classes to accept both string and dictionary messages, providing developers with the flexibility to pass structured error information while maintaining full backward compatibility. All exception classes in
aws_lambda_powertools/event_handler/exceptions.pynow supportstr | dicttype annotations and include comprehensive docstrings.Changes
1. Update Parameter types
msg: strtomsg: str | dictacross all exception classes inaws_lambda_powertools/event_handler/exceptions.py2. Documentation Improvements
msgcan be either a string or dictionary3. Affected Exception Classes
ServiceErrorBadRequestErrorUnauthorizedErrorForbiddenErrorNotFoundErrorRequestTimeoutErrorRequestEntityTooLargeErrorInternalServerErrorServiceUnavailableErrorUser experience
Before Changes
Users were limited to simple string error messages:
After Changes
Users can now choose between simple strings or rich structured error objects:
Option 1: String messages (backward compatible)
Option 2: Structured dictionary messages (new capability)
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.