gpt4 book ai didi

groovy - 在 Groovy 中重新引发异常

转载 作者:行者123 更新时间:2023-12-03 09:13:26 25 4
gpt4 key购买 nike

我有一个带有 try-catch 语句的 groovy 脚本。现在我想重新引发异常,以便调用者也可以对该异常使用react。有规范的方法可以做到这一点吗?

最佳答案

如果能举个例子就好了...

但你的意思是:

Transaction tx = startTransaction()
try {
tx.doSomething()
tx.commit()
}
catch(ex) {
tx.rollback()
throw new MyTransactionFailedException("rolling back", ex)
}

关于groovy - 在 Groovy 中重新引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39767255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com