Skip to content

Handle exceptions raised in middleware #378

Description

@jeremyschulman

I would like to be able to handle any exceptions that are raised by custom middleware. I expected (hoped) that these
exceptions would be caught by the @app.error registered handler; but this was not the case. I am looking for the
correct way to catch these exceptions. Thank you.

Reproducible in:

slack-bolt @ file:///Users/jeremy.schulman/Library/Caches/pypoetry/artifacts/31/56/a3/cbe3c0937d465ddd945b547d34863a08eac8399ae0dfd15353626d4728/slack_bolt-1.6.1-py2.py3-none-any.whl
slack-rbac==0.1.0
slack-sdk @ file:///Users/jeremy.schulman/Library/Caches/pypoetry/artifacts/90/be/66/e7459a165f28d4862e6a844a8a667019bb88087b17641413be0e03f8ec/slack_sdk-3.6.0-py2.py3-none-any.whl
Python 3.8.8
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H1217
Darwin Kernel Version 19.6.0: Thu May  6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64

Steps to reproduce:

  1. Created a custom middleware listener
  2. Registered an @app.error to catch exceptions
  3. Raised a RuntimeError exception in that middleware

Expected result:

Want to see the @app.error handler catch the error caused by the raise in middleware

Actual result:

Observed the exception stacktrace in the console output

Activity

  1. added this to the 1.7.0 milestone on Jun 14, 2021
  2. seratch commented on Jun 14, 2021

    @seratch
    Contributor

    Hi @jeremyschulman, thanks for taking the time to report this issue! And you are right. This behavior should be improved for better alignment with bolt-js. We will fix this issue in next minor version (v1.7.0).

  3. jeremyschulman commented on Jun 14, 2021

    @jeremyschulman
    Author

    @seratch - thank you, much appreciated!

  4. self-assigned this
    on Jun 14, 2021
  5. added a commit that references this issue on Jul 14, 2021
    fa4988f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions