February 26, 2007 Re: Exception Safe Programming | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | How do I read the exceptions thrown in the main > scope(failure) ? Or should I just put everything in a try-catch ? |
February 26, 2007 Re: Exception Safe Programming | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | 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.
|
February 26, 2007 Re: Exception Safe Programming | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tyler Knott | Okay, thanks.
>> 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.
|
Copyright © 1999-2021 by the D Language Foundation