如何修改 Railo 中的异常对象
try {
// some error
} catch (any e) {
e.extendedInfo = 'New extended info';
//throw(e);
//cfcatch.extendedInfo = 'New extended info';
rethrow;
}
当我(重新)捕获此异常时,扩展信息不会显示。我想要发生的是引发的异常保留其所有预捕获属性,包括原始 tagContext 和行号等,但获取 ExtendedInfo 的新值。
我尝试将 e
的属性复制到新的 attributeCollection 中,并使用 throw(e)
或
但随后上下文发生更改,并且错误显示错误的源代码行。
当我这样做时,有一种方法可以删除最顶层的堆栈对象,因此似乎从调用上下文中抛出了异常。即:
function myRethrow(e) (
throw(e); // <!-- error is actually throw here BUT ...
)
myRethrow(e); // <-- error should appear to have 'happened' here
使用 Railo 3.2
try {
// some error
} catch (any e) {
e.extendedInfo = 'New extended info';
//throw(e);
//cfcatch.extendedInfo = 'New extended info';
rethrow;
}
When I (re)catch this exception the extendedInfo is not displayed. What I want to happen is the raised exception keeps all of its pre-catch properties including the original tagContext and line numbers etc but gets a new value for extendedInfo.
I've tried copying the attributes of e
into a new attributeCollection and throwing that with throw(e)
or <cfthrow attributeCollection="#e#" />
but then the context is changed and the error displays the wrong line of source code.
While I'm at it is there a way to to drop the topmost stack object so an exception appears to have been thrown from the calling context. ie:
function myRethrow(e) (
throw(e); // <!-- error is actually throw here BUT ...
)
myRethrow(e); // <-- error should appear to have 'happened' here
Using Railo 3.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你可以像这样使用
throw
函数:对我有用。
I think you can use
throw
function like this:Works for me.