Storing Error codes and its messages
I have a small application in which I need to show error messages based on the error codes. There are three choices that comes to my mind for storing these error codes and its error message.
1. Use simple java interface which defined keys and its values(error
messages)
2. Use Resource Bundles (I dont have any localization requirement)
3. Use XML (Will create unnecessary overhead /complexity)
Is there any disadvantage of the 1st method. Any comments ?
TIA
Ashwani
[522 byte] By [
ash_ka] at [2007-9-28 4:57:54]

Hi,
> I have a small application in which I need to show
> error messages based on the error codes. There are
> three choices that comes to my mind for storing these
> error codes and its error message.
>
> 1. Use simple java interface which defined keys and
> its values(error
> messages)
By using this way you can develop fast.It is simple but difficult for non-tech guy to handle,I mean system administrator.
2. Use Resource Bundles (I dont have any localization
> requirement)
I did not understand this can you explain this in details?
> 3. Use XML (Will create unnecessary overhead
> /complexity)
>
Definetly this be complex to build and will occupy more allocations, but for small applications this will be better.In case of storing the values in the interface you will have to compile the files every now and then but for putting the value in xml you have to edit the file and just save it before running the smaller aplication.
With xml type the system administrator can play but not with the interfaces and you would not like.
Regards
Vicky
If all you want is to map an ERROR_NUMBER to a specific message:
158 -> "General Arithmetic Error"
then I would strongly recommend that you use a properties file based method.
Whether you use a plain properties file, or a resource bundle doesn't matter. The benefits of this approach are: better maintenanace!
- anyone can edit the error messages. You don't have to have your Java certification to change a text file.
- you don't need to recompile every time you need to edit/add a new error message.
You can also mix this with the use of java.text.MessageFormat, and have error messages like:
159 -> "Divide by cero error: {1}/0"
where {1} would get expanded into the value you are trying to divide by cero.
Manuel Amago.