The Right Approach to Exceptions

Juan Manuel Cabo juanmanuel.cabo at
Mon Feb 20 11:17:58 PST 2012

I like the idea!

Remember please for anyone reading: Use positional arguments in
format strings. Otherwise:

	"The '%s' file's size is %d which is wrong"

        translated to

	"El tamaño %d es incorrecto para el archivo %s"

will be trouble. Instead please do:

        "The '%1$s' file's size is %2$d which is wrong"

specially for standard library messages. This would be very helpful!


> into this:
> try
>     getopt(args, ...)
> catch(Exception e)
> {
>     stderr.writeln(stringTemplate(typeid(e).toString(),;
>     return -1;
> }
> The stringTemplate function loads the formatting template from a table indexed on typeid(e).toString() and formats it
> with the info. It's simple factorization.
> Andrei

More information about the Digitalmars-d mailing list