The Right Approach to Exceptions
Juan Manuel Cabo
juanmanuel.cabo at gmail.com
Tue Feb 21 07:38:14 PST 2012
> This works:
> // note: the int parameter above isn't static
> dbConn.query("select age from people where id='foobar'");
> throw new WithErrorCode!FileNotFoundException(
> db.rs.getValue(1), "file not found");
...
> Can you offer a real world use-case where the above isn't sufficient?
What happened is that a file wasn't found. What one wants to catch is
a FileNotFoundException.
Do you suggest that I have to:
try {
...
} catch (FileNotFoundException ex) {
...
} catch (WithErrorCode!FileNotFoundException ex) {
...
} catch (WithRainbows!FileNotFoundException ex) {
...
}
and so on?
--jm
More information about the Digitalmars-d
mailing list