Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在异常和抛出相同类型的异常之后恢复数据。如果在编译时我不知道异常的类型,是否有可能?谢谢。
您需要提供更多详细信息;是RuntimeException吗?如果没有,你已经抓住了它,只需重新抛出它。如果没有 try/catch,你需要把它包起来,然后扔掉。
RuntimeException
如果您无权访问代码,则可以使用 AspectJ 之类的东西。
你有没有试过这个:
try { // your code here. } catch (Exception exception) { // your code here. throw exception; }