如何在 MULE 中将堆栈跟踪返回给客户端..?
有谁知道当 MULE 中发生运行时异常时如何在浏览器上打印完整堆栈跟踪?
当发生运行时异常时,MULE 会向客户端抛出 500 服务器错误,但不会向客户端显示任何详细信息。它在控制台或日志文件中打印整个堆栈跟踪(如下所示):
Root Exception stack trace:
java.sql.SQLException: Invalid column name
at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3677)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2749)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true'
for everything)
我可以在浏览器上(向客户端)显示相同的堆栈跟踪..?
如果可能的话,还告诉我如何打开或关闭浏览器上堆栈跟踪的打印..?
(可能在将来的某个时候,我不想在浏览器上显示堆栈跟踪)
Does anybody know how to print full stack trace on the Browser, when a Runtime Exception occurs in MULE..??
When a runtime Exception occurs, MULE throws a 500 Server Error to the client , but shows no details to the client. It prints the whole stack trace in Console or Log Files (like the following) :
Root Exception stack trace:
java.sql.SQLException: Invalid column name
at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3677)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2749)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true'
for everything)
Can i show the same stack Trace on the Browser (to the client)..??
And if possible , then also tell me how to switch ON or OFF printing of Stack Trace on Browser..??
(It may be possible that sometime in future , i dont want to show stack trace on browser)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是可能的。我假设您使用的是常规 HTTP 端点,并且这是 REST 类型服务(?)如果是这样,您可以简单地在导致异常的代码周围放置一个 try/catch 并返回您想要的任何文本。
还有异常策略(http://www.mulesoft.org/documentation/display/MULE3USER/Error+Handling)用于进行更复杂的错误处理,但听起来您正在寻找上面的简单答案。
如果这不能回答您的问题,请提供有关您的 mule 配置和引发异常的服务的更多信息。
Yes this is possible. I assume you are using a regular HTTP endpoint and this is a REST type service(?) If so, you can simply put a try/catch around the code causing the exception and return whatever text you want.
There are also exception strategies (http://www.mulesoft.org/documentation/display/MULE3USER/Error+Handling) for doing more sophisticated error handling, but it sounds like you are looking for the simple answer above.
If this doesn't answer your question, please provide more info about your mule config and the service that is raising the exception.
Mule 中没有现成的东西可以做到这一点。您必须实现一个异常处理程序,该处理程序将格式化消息异常负载中的堆栈跟踪并将其返回给调用者。
在您的情况下,HTTP 传输有一个特殊性,可以在 HttpMessageReceiver 代码中找到:
这意味着当异常出现在顶层时,失败消息响应的创建是不可定制的:您会得到这个非常技术性的消息回来就是这样。
我看到有两个选项可以解决您的问题:
There is nothing out of the box in Mule to do that. You have to implement an exception handler that will format the stacktrace in the Message exception payload and return it to the caller.
In your case, the HTTP transport has a particularity that can be found in the HttpMessageReceiver code:
This means that when an exception crops-up to the top level, the creation of the failure message response is not customizable: you get this pretty technical message back and that is all.
I see two options to solve your problem: