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
Fix #378 by adding middleware error handlers #401
Conversation
except Exception as error: | ||
resp = BoltResponse(status=500, body="") | ||
self._middleware_error_handler.handle( | ||
error=error, | ||
request=req, | ||
response=resp, | ||
) | ||
return resp |
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.
These lines of code are the essential changes in this pull request.
@@ -664,6 +686,10 @@ def custom_error_handler(error, body, logger): | |||
logger=self._framework_logger, | |||
func=func, | |||
) | |||
self._middleware_error_handler = CustomMiddlewareErrorHandler( |
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.
For backward-compatibility, I didn't rename and modify the existing CustomListenerErrorHandler
to be reusable for this. In the future major version, we may want to have a unified interface for these two error handlers. They are mostly the same.
@@ -1,58 +0,0 @@ | |||
from logging import Logger |
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.
As this internal code is no longer used, we can safely delete the whole. We've switched to slack_bolt/kwargs_inject/async_utils.py
Codecov Report
@@ Coverage Diff @@
## main #401 +/- ##
==========================================
+ Coverage 89.65% 91.72% +2.07%
==========================================
Files 128 167 +39
Lines 3585 5436 +1851
==========================================
+ Hits 3214 4986 +1772
- Misses 371 450 +79
Continue to review full report at Codecov.
|
This pull request fixes #378 by applying the following changes:
App
andAsyncApp
@app.error
registration to enable the custom error handler for both middleware and listenersCategory (place an
x
in each of the[ ]
)slack_bolt.App
and/or its core componentsslack_bolt.async_app.AsyncApp
and/or its core componentsslack_bolt.adapter
/docs
Requirements (place an
x
in each[ ]
)Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
./scripts/install_all_and_run_tests.sh
after making the changes.