Particular exceptions names

pascal111 judas.the.messiah.111 at gmail.com
Tue Jul 26 23:43:59 UTC 2022


In next example code, it used user-made exception, but what if 
I'm looking for a particular exception? from where can I get 
particular exception to arise it?


     import std.stdio;
     import std.string;

     string division(int a, int b) {
        string result = "";

        try {
           if( b == 0 ) {
              throw new Exception("Cannot divide by zero!");
           } else {
              result = format("%s",a/b);
           }
        } catch (Exception e) {
           result = e.msg;
        }

        return result;
     }

     void main () {
        int x = 50;
        int y = 0;

        writeln(division(x, y));

        y = 10;
        writeln(division(x, y));
     }

source site:
https://www.tutorialspoint.com/d_programming/d_programming_exception_handling.htm


More information about the Digitalmars-d-learn mailing list