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

  • List of exceptions? DMon via Digitalmars-d-learn
    • Re: List of exceptio... Ali Çehreli via Digitalmars-d-learn
      • Re: List of exce... DMon via Digitalmars-d-learn
        • Re: List of ... Ali Çehreli via Digitalmars-d-learn
          • Re: List... DMon via Digitalmars-d-learn
            • Re:... Ali Çehreli via Digitalmars-d-learn
              • ... DMon via Digitalmars-d-learn
                • ... Ali Çehreli via Digitalmars-d-learn
                • ... DMon via Digitalmars-d-learn
                • ... Imperatorn via Digitalmars-d-learn
                • ... Dominikus Dittes Scherkl via Digitalmars-d-learn
                • ... DMon via Digitalmars-d-learn
                • ... Ali Çehreli via Digitalmars-d-learn
    • Re: List of exceptio... Imperatorn via Digitalmars-d-learn

Reply via email to