views:

37

answers:

1

Hello Guys,

I would like to know if there are any recommended patterns for errorKey -> errorMessage look up? I am trying to improve my exception handling techniques and would be grateful for some ideas.

I am using some third party software and when an exception occurs they return an error key in the format THIRD_PARTY_ERROR_KEY. This maps to some awful message that the user should not see. I think I could use a static class that takes the key and looks up the message from a resource bundle but I would like some recommendations on some nice pattern to do this.

I am using Spring 2.5.6 and thought there might be something sexier that I could do.

Cheers.

+1  A: 

Are you aware of Spring MessageSource? I think that's the ticket here. Look at the reference docs.

duffymo
Yeah was skirting around that. Cheers.
LadyCoconut
came here to suggest JDK ResourceBundle, which Spring's MessageSource basically wraps - so I second this suggestion
matt b