I am working with MySQL server, Delphi and Zeoslib. Whenever I try to connect to my MySQL server running in another machine and it is shutoff on purpose, it throws an exception that it can't connect. I want to be able to suppress this exception or handle it properly. But my code doesn't seem to work.
Here is my code:
try
WebSQLCon.Connect;
except
on E: Exception do begin
WebSQLCon.Disconnect;
end;
end;
I can't see anything wrong with this code. So, why is it not handling the exception instead of popping up the message?
UPDATE:
What you are seeing is the debugger breaking on the exception. The dialog you have presented in your screenshot is not displayed by the program. Rather the debugger displayed it. You can click on the Continue button to proceed.
If you wish to disable this dialog you can do so from the debugger area of the IDE options. These settings can be found under Tools | Options | Debugger Options | Language Exceptions. There you can uncheck Notify on language exceptions to suppress this dialog. However, that's not generally something to be recommended. You might perhaps suppress this exception class by adding to the list of exceptions that are ignored. However, now that you know what causes this you may prefer just to press the Continue button.
Note that as discussed in the comments, it seems very likely that your swallow all exception handler code is the wrong way to deal with the issue of Connect
failing.