Exception Safe Programming

Tyler Knott tywebmail at mailcity.com
Sun Feb 25 19:36:24 PST 2007


Saaa wrote:
> How do I read the exceptions thrown in the main > scope(failure) ?
> Or should I just put everything in a try-catch ?
> 
> 
You can't handle any exceptions outside of try-catch-finally blocks.  The scope 
guards exist to ensure that any cleanup necessary (such as closing network 
connections or releasing mutexes in multithreaded programs) gets performed 
before all references to the associated resources are lost.  To actually access 
the exceptions the exception needs to be thrown in the scope of a try block 
(somewhere, it doesn't need to be the immediate function) and that try block 
must have a catch and/or finally block.


More information about the Digitalmars-d-learn mailing list