List of exceptions?
Ali Çehreli
acehreli at yahoo.com
Sat Oct 10 16:00:26 UTC 2020
On 10/10/20 8:46 AM, DMon wrote:
> On Saturday, 10 October 2020 at 14:56:31 UTC, Ali Çehreli wrote:
>> On 10/10/20 5:12 AM, DMon wrote:
>>> Is there a list of a list of the exceptions or what can be used with
>>> catch?
>>
>> Only Throwable and classes that are derived from it can be thrown and
>> caught.
>>
>> Ali
>
> Thanks for the reply.
>
> I am looking to catch exceptions explicitly and get that it does not
> have to be. Is explicite cathing the best practice or is implicite how
> its done?
I don't know implicit catching. I would like to learn from others.
I think the common rules are:
- Don't catch anything
- Unless you can do something about it (e.g. ask the user something to
retry, augment it, etc.)
I almost always catch in main() (or a thread's main function) and only
to print a clean error message:
void main() {
try {
// ...
} catch (Exception e) {
stderr.writefln!"ERROR: %s"(e.msg);
}
}
That's it for me. :)
Ali
More information about the Digitalmars-d-learn
mailing list