Why does Indy raise exceptions as part of its normal operation?

Previous  Top  Next

All exceptions are not errors. Exceptions are exactly that - exceptions. Delphi / C++ Builder use exceptions to handle errors in an elegant way. However exceptions have other uses besides errors as well.


EAbort is one example of an exception that is not necessarily an error. Exceptions such as these are used to modify standard program flow and communicate information to a higher calling level where they are trapped.


Indy uses exceptions in such a way as well. There are two primary places that Indy does so and are addressed in the following two questions:


Why do I get 10038 exceptions raised when I shut down my servers?
Why do I keep getting EIdConnClosedGracefully exceptions?


The 10038 exception for clients is an error and for servers sometimes is too. However the EIdConnClosedGracefully for servers is trapped and handled. While EIdConnClosedGracefully can be an error it is often a "normal" condition. Because of this, it descends from EIdSilentException. You can add EIdSilentException to your debugger options to tell the debugger not to stop on these exceptions. The exception will still occur and your EXE will still function the same, however the debugger just wont stop on them for debugging.