Boost logo

Boost Users :

From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2008-02-19 11:20:50


>> Moreover, some english strings seem to be hard-coded in program_options
>> (exception messages, etc.) There should be another way of handling
>> cmdline errors - we can't presume that the user understands english
>> text. And there does not seem to be a way of translating the po
>> exceptions to localized strings without accessing/changing some po
>> internals.
>>
>
> I suspect all boost libraries share this problem, and nobody came with
> a nice solution for solving this.
>
> I can surely provide a hook, specific for program_options, that is called
> to translate messages.
>
Sure, but program_options is in fact implementation of some UI so the
need for user interaction is higher than with some other libraries.

I think that providing some additional data members in the exception
classes would be sufficient. That way, you don't need to provide any
hooks at all.

The current pattern for using exceptions is something like

  throw my_exception("some text "+param+": some other text "+param2);

(sometimes the string construction is in my_exception's constructor).

I'd rather see

  throw my_exception(param, param2);

and somewhere in my_exception:

class my_exception {
  ....
public:
  string param;
  string param2;

  string what() const {
     return "some text "+param+": some other text "+param2;
  }
}

Cheers,
Filip


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net