How to catch an exception of Interbase on Connect when gdb file doesn't exist on a given path

618 views Asked by At

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????

1

There are 1 answers

2
Tommy Andersen On

Could it be that the exception is not inherited from the base exception class Exception, if so have you tried adding a catch(...) 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?