Java 如何处理 Talend 中的错误和异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24051103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to handle errors and exceptions in Talend
提问by user3141034
I am new in talend. I am trying to catch run time errors and exceptions and display meaningful message to the end user, but i am failed to do this. I saw many tutorials they use different pallets. If in one tutorial tLogCatcher is used whereas in other file it is using tAssertCatcher. I tried with both but could not do. With that i am confuse that where i have to write xpath to replace the error or exception with my own message.Can anybody help me that how to catch errors and exceptions and show meaningful messages.Thanks
我是新来的。我正在尝试捕获运行时错误和异常并向最终用户显示有意义的消息,但我没有做到这一点。我看到很多教程他们使用不同的托盘。如果在一个教程中使用 tLogCatcher,而在其他文件中它使用 tAssertCatcher。我尝试了两者,但无法做到。对此,我很困惑,我必须在哪里编写 xpath 来用我自己的消息替换错误或异常。有人可以帮助我了解如何捕获错误和异常并显示有意义的消息。谢谢
回答by ydaetskcoR
You can use the tLogCatcher component to catch any errors or warnings thrown by your Talend job. To output these you can then link this to either a tLogRow component to throw them to the console (and run logs) or out to any output that Talend can connect to such as a flat file, database or even send them in an email with a tSendMail component.
您可以使用 tLogCatcher 组件来捕获 Talend 作业引发的任何错误或警告。要输出这些,您可以将其链接到 tLogRow 组件以将它们发送到控制台(并运行日志)或输出到 Talend 可以连接到的任何输出,例如平面文件、数据库,甚至可以通过电子邮件发送它们tSendMail 组件。
If you wish to change the wording of the messages being thrown and then blindly passed on by the tLogCatcher then you could use a tMap or a tReplace or other similar component to look for your input string (the original error message) and replace it for a message of your choosing before outputting it to either the logs or some other target.
如果您希望更改被抛出然后被 tLogCatcher 盲目传递的消息的措辞,那么您可以使用 tMap 或 tReplace 或其他类似组件来查找您的输入字符串(原始错误消息)并将其替换为在将其输出到日志或其他目标之前选择的消息。