In my localized application, I throw an ArgumentException as follows:
throw ArgumentException("LocalizedParamName", "LocalizedErrorMessage");
And I'll catch him like this:
catch (Exception ex)
{
Display(ex.Message);
}
I get an error message:
LocalizedErrorMessage Parameter Name: LocalizedParamName
The problem here is: "Parameter Name:", which is written in English, not in my application language. I claim that the string is in the language of the .NET platform. Can anyone confirm this?
A workaround does this:
catch (ArgumentException ex)
{
Display((ex as Exception).Message + "\n" + "Translated(Parameter name:)"+ ex.ParamName);
}
catch (Exception ex)
{
Display(ex.Message);
}
Is there an even more elegant way?
source
share