www.digitalmars.com         C & C++   DMDScript  

D - Localisation for exceptions

reply "Matthew Wilson" <matthew stlsoft.org> writes:
I presume at the moment that people are including specific strings in their
exceptions, eg. throw new FileException("Failed to open file", ...).

Has anyone thought about localisation issues?

Specifically, are we expecting to do the translation within our own code,
i.e. lookup a string from a given resource error-id, as in


class X
{
public:
  void y()
  {
      . . . // try some file opening

      int         err = . . .;
      char[]    message =
ThirdPartyVendor.Locale.LocaliseString(FILEOPEN_FAIL_EXCEPTION_MESSAGE)

      throw new FileException(message, err);


private:
    const int FILEOPEN_FAIL_EXCEPTION_MESSAGE = . . .;


or do have overloads for the specific exception classes to take string ids.
In which case, where are the lookups, and what about the standard
exceptions/errors (in Phobos)?
Aug 20 2003
parent "Philippe Mori" <philippe_mori hotmail.com> writes:
 I presume at the moment that people are including specific strings in
their
 exceptions, eg. throw new FileException("Failed to open file", ...).

 Has anyone thought about localisation issues?

 Specifically, are we expecting to do the translation within our own code,
 i.e. lookup a string from a given resource error-id, as in
Normally, the string is not intended to be viewed by the user but only to the programmer in the debug version. The reason is that for a user, it is preferable to give a user friendly message in the context where the exception is catched... What we were doing at my previous work (in C++): But fot some classes we were using ressource for the strings but they where almost never displayed directly to the user but this was done in case we display some details to the user... For predefined exceptions, we were using them as it most of the time.
Aug 20 2003