How do I catch an exception in a decorator but allow the caller to catch it as well?

前端 未结 2 969
一向
一向 2020-12-30 04:03

I have a python function that may raise an exception. The caller catches the exception and deals with it. Now I would like to add a decorator to that function that also<

2条回答
  •  感动是毒
    2020-12-30 05:05

    Just use raise; (i.e. do not raise anything specific, just raise;) in a catch block to re-raise the exception without "resetting" the traceback.

提交回复
热议问题