开发者

Should I use error codes for exception handling in a multi-language app?

In exception handling, in a multi-language app, is it bad to store English开发者_StackOverflow社区 in the code (strings in classes)? Is it better to use just error codes and document these? I saw a best practise somewhere that your code should not have strings which are exception messages etc (although perhaps they can be refactored out and converted to other languages at will).

Thanks


Why don't you place urls instead of error codes. This could be in the form of: http://myapp.com/help/error/434hb4b3.html&language=english

This way you are free to:

  1. Modify the help on the error message later without having to update the software
  2. Easily add languages
  3. Make the help for this error message a wiki so the users can modify the page and include workarounds etc.


You don't mention the language/framework you are developing in, however...

Another solution would be to put your error descriptions into localised resource files. This way everything ships together and customer not have to have an internet connection access error details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜