G
Guest
I have an hard time figuring out how to deal with localization and Exception
messages.
I have some options:
1) Standardize on english.
2) Pass an "Error Number" to my exceptions, which would ultimately translate
to something localized if the app ever wants to display it (by calling the
Message property).
3) Use the System.Resources namespace classes each time I throw an exception
to make sure the right message is passed to the exception at creation.
If I want to localize the throwing of an ArgumentException exception, for
example, then only the first method (obviously) and the third method would
localize the error message. With the other method, I would have to subclass
ArgumentException to my own LocalizedArgumentException that takes an error
number (which map to a localized error message) in argument.
Anyway, I'm really stuck here, conceptually speaking. I don't know what are
the best practices regarding that matter.
Etienne Fortin
Of the three methods, only the third one, which I don't like (efficiency
reason), allows localization of standard .NET Framwork exceptions throwing.
messages.
I have some options:
1) Standardize on english.
2) Pass an "Error Number" to my exceptions, which would ultimately translate
to something localized if the app ever wants to display it (by calling the
Message property).
3) Use the System.Resources namespace classes each time I throw an exception
to make sure the right message is passed to the exception at creation.
If I want to localize the throwing of an ArgumentException exception, for
example, then only the first method (obviously) and the third method would
localize the error message. With the other method, I would have to subclass
ArgumentException to my own LocalizedArgumentException that takes an error
number (which map to a localized error message) in argument.
Anyway, I'm really stuck here, conceptually speaking. I don't know what are
the best practices regarding that matter.
Etienne Fortin
Of the three methods, only the third one, which I don't like (efficiency
reason), allows localization of standard .NET Framwork exceptions throwing.