Maybe I don't understand this, but as far as I understand you really need to reconsider the program structure. If someone is typing the wrong password then there should be a way to enter the password again (at least one time... depending on the security settings...). And without a proper password there should not be any connection.
On the other hand it's not necessary to know all the possible exceptions that can happen in a certain program at a certain point. Exactly for this there is TRY_EXCEPT_END without any special exception class. Then you catch all exceptions that can happen. If you like to do something special in case there is a certain exception, then you can figure out what exception class (for example: EDatabaseError) that is and do something in that case. But that is not necessary in general... you can, but there is no must.
For example:
Begin
Try
// Do something ...
Except
End;
End;
If you use this then any exception that occurs will be "terminated" and the user won't see anything of it. This is normally not a good idea, but can be used if you don't want to see any message. In case "Do something" is something that is visible to the user if it's not working and a message will only bother him...
Begin
Try
// Do something ...
Except
On E: Exception Do
Begin
Log('My Own Text....'+E.Message+sLineBreak+E.ClassName);
// set values back or close windows or free things... whatever ...
End;
End;
End;
This can be used if you want to use your own logging and if you need to do special things so that the program can secure run on if the exception won't crash the whole program...
Begin
Try
// Do something ...
Except
On E: Exception Do
Begin
Log('My Own Text....'+E.Message+sLineBreak+E.ClassName);
// set values back or close windows or free things... whatever ...
Raise;
End;
End;
End;
This can be used if you need to handle the exception at a higher level elsewhere in the code after you got your log and other things done.
Begin
Try
// Do something ...
Except
On E: Exception Do
Begin
Log('My Own Text....'+E.Message+sLineBreak+E.ClassName);
// set values back or close windows or free things... whatever ...
ShowMyLog;
Raise Exception.Create('ERROR xyz...');
End;
End;
End;
This can be used if you want your own exception name...
And if you use for example API functions (Windows) then you need to check the return value instead of using TRY_EXCEPT_END. Normally they won't throw exceptions...
Just my 2 cents...