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
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?
- Particular exceptions names pascal111 via Digitalmars-d-learn
- Re: Particular exceptions names frame via Digitalmars-d-learn
- Re: Particular exceptions names Ali Çehreli via Digitalmars-d-learn
- Re: Particular exceptions na... pascal111 via Digitalmars-d-learn
- Re: Particular exceptions na... kdevel via Digitalmars-d-learn
- Re: Particular exceptions names kdevel via Digitalmars-d-learn