The Right Approach to Exceptions

deadalnix deadalnix at gmail.com
Mon Feb 20 11:29:31 PST 2012


Why don't we use .tupleof for such a thing ?

Le 20/02/2012 20:17, Juan Manuel Cabo a écrit :
> 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!
>
> --jm
>
>
>
>> into this:
>>
>> try
>>      getopt(args, ...)
>> catch(Exception e)
>> {
>>      stderr.writeln(stringTemplate(typeid(e).toString(), e.info));
>>      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