On 2012-02-19 13:27, Juan Manuel Cabo wrote:
How about adding a string[string] or a variant[string] to the Exception
class, so one can know details about the subclassed exception without
downcasting? How ugly would that be?

For instance:

...
catch (Exception ex) {
if ("transient" in ex.details) {
repeatOneMoreTime();
}
if ("i18n_code" in ex.details) {
log(translate(ex.details["i18n_code"]));
}
}
...

Details can be standard by convention or otherwise custom.
(I can see that this can lead to messy proliferation of details, but at
least solves most of the issues).

How would you know which keys are available in "ex.details", documentation?

--
/Jacob Carlborg

Reply via email to