PowerBuilder 在调试模式下因 try/catch 块内的错误而崩溃
在调试模式下,powerbuilder(版本 10.5)会抛出应用程序执行错误并终止应用程序,因为错误是由放入 try/catch 块内的语句引发的?
例如,下面的第 3 行抛出“超出数组边界”错误,并且应用程序被终止。我怎样才能克服这个(已处理的)错误并调试其余的代码?
try
// lstr_passed_values = message.powerobjectparm
ls_symv_no = gstr_symv_passed_values.is_values[1]
if isnull(ls_symv_no) or ls_symv_no = "" then
is_symv_no="%"
else
is_symv_no = ls_symv_no
gstr_symv_passed_values.is_values[1]=""
end if
catch (throwable err)
is_symv_no="%"
end try
When in debug mode, powerbuilder (ver 10.5) throws application execution error and terminates the application, for errors raised by statements put inside try/catch blocks?
For example line 3 below throws, an "array boundary exceeded" error and the application is terminated. How can I overcome this (handled) error and debug the rest of the code?
try
// lstr_passed_values = message.powerobjectparm
ls_symv_no = gstr_symv_passed_values.is_values[1]
if isnull(ls_symv_no) or ls_symv_no = "" then
is_symv_no="%"
else
is_symv_no = ls_symv_no
gstr_symv_passed_values.is_values[1]=""
end if
catch (throwable err)
is_symv_no="%"
end try
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调试时遇到困难?
我想说 PB 调试器的行为是正常的。如果您尝试真正掌握调试的概念,则应该逐行单步执行代码。通过向您提供“超出数组边界”错误,调试器实际上已经证明您的代码中存在潜在的未处理异常(这就是您将 Try-Catch 代码放在那里的原因)。
在调试器实际到达该点之前,不会抛出异常。这违背了调试器的目的。你明白我的意思吗?
现在,如果您想在调试模式下跳过特定代码块,则需要使用“设置下一条语句”。
从下面修改后的示例代码中,在第 1 行设置断点。调试器到达断点后,右键单击“编辑变量”字符串“is_symv_no”。然后将光标移到第14行,点击“设置下一条语句”。这将绕过整个 try-catch 例程(第 2-13 行)并允许您的程序继续。
Struggling with debug?
I would say the PB Debugger is behaving as it should. If you try to really grasp the concept of debugging, it's suppose to step through your code line by line. By giving you an "Array boundary exceeded" error, the debugger has actually proven that there's a potential unhandled exception in your code (which is why you placed the Try-Catch code there).
It's not suppose to Throw the exception until the Debugger has actually reached that point. This defeats the purpose of a debugger. Do you get what I mean?
Now if you want to skip a particular code block while on debug mode, you need to use "Set Next Statement".
From your modified sample code below, set the breakpoint on Line 1. Once the debugger reaches the breakpoint, right-click "Edit Variable" the string "is_symv_no". Then move the point cursor on Line 14 and click "Set Next Statement". That will bypass the whole try-catch routine (Lines 2-13) and allow your program to continue.
如果有人偶然发现这个线程 - 如果在调试时单击“忽略”无法让您完成 TRY...CATCH 块,那么为了避免崩溃,请转到 PB 调试器中的“调试...异常”。对于适当的异常类型,选择“继续”选项。
In case anyone stumbles upon this thread - if clicking on "Ignore" doesn't get you through the TRY...CATCH block while debugging, then to avoid the crashing, go to Debug...Exceptions in the PB Debugger. Choose the option to "Continue" for the appropriate exception type.