当给定路径上不存在 gdb 文件时,如何捕获 Interbase on Connect 的异常
我的机器上安装了 fib+ comps,并且 尝试捕获连接时的 Interbase 异常,但
try {
DM->dBase->Connected=false;
DM->dBase->DBName=DBPATH;
DM->dBase->Connected=true;
} catch (Exception &e) {
ShowMessage("Exception "+ (AnsiString(e.Message)));
}
如果我将 DBPATH 更改为不存在的 gdb 文件,我无法捕获一个异常,它会抛出一个异常,例如
由系统错误导致的失败执行,该错误阻止了后续语句的成功执行。文件的 I/O 错误。尝试打开文件时出错
是否可以捕获此异常??? 我调试了我的代码,但光标直到尝试捕获异常块才出现,在此之前我提到的异常出现了!
如果是的话我怎样才能捕获这种异常???
I have fib+ comps installed on my machine and
trying to catch Interbase exception on connecting but one exception I cannot catch
try {
DM->dBase->Connected=false;
DM->dBase->DBName=DBPATH;
DM->dBase->Connected=true;
} catch (Exception &e) {
ShowMessage("Exception "+ (AnsiString(e.Message)));
}
if i change the DBPATH to a non-existent gdb file it throws an exception like
Unsuccessful execution caused by a system error that precludes successful exection of subsequent statements. I/O error for file .Error while trying to open file
Is it possible to catch this exception????
I debugged my code but cursor didn't come till try catch exception block and before that my aforementioned exception comes on!!!
If yes how can i catch this kind of exception????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否该异常不是从异常基类
Exception
继承的,如果是的话,您是否也尝试过添加catch(...)
?我不确定我完全理解你的帖子,但你所看到的是否有可能不是,你的程序没有捕获异常。是调试器在您的 catch 语句处理它之前将其呈现给您吗?如果是这种情况,那么您可以告诉调试器不要为您呈现此异常类型。
如果在调试器之外运行程序,异常是否会出现?
Could it be that the exception is not inherited from the base exception class
Exception
, if so have you tried adding acatch(...)
as well?I'm not sure I understand your post entirely, but is it possible that what you see is not, that your program isn't catching the exception. It is that the debugger presents it to you before it is being handled by your catch statement? If this is the case then you can tell the debugger to not present this exception type for you.
Does the exception arrive if you run the program outside the debugger?