Is there a way to catch all unhandled exceptions thrown by a given class?

后端 未结 6 2104
你的背包
你的背包 2020-12-18 13:21

I know how to catch all unhandled exceptions in a given thread, but wondering if there is a way to catch all unhandled exceptions thrown by a given class in

6条回答
  •  忘掉有多难
    2020-12-18 14:25

    I don't know of any way to catch all unhandled exceptions thrown by a given class.

    In order to achieve what you want to do, one thing is to create a wrapper class that calls into the original class and catches all exceptions. Then in the original class, you can use the wrapper class, without having to write the try catch blocks every time.

提交回复
热议问题