View Single Post
  #2 (permalink)  
Old November 11th, 2005, 06:31 AM
dleal dleal is offline
Registered User
Join Date: Oct 2005
Location: Madrid, M, Spain.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to dleal Send a message via MSN to dleal Send a message via Yahoo to dleal

(I respond in part to my self)

Following the comment from the Expert One-on-One J2EE Design and Development (R. Johnson et al.):

"Unless we are able to use a common base class for all exceptions in an application – something that isn't possible if we mix checked and unchecked exceptions – we will need to make our exceptions implement an ErrorCoded or similarly named interface that defines a method such as this: String getErrorCode();"

..."we are able to distinguish between error messages intended for end users and those intended for developers. Messages inside exceptions (returned by the getMessage() method) should be used for logging, and targeted to developers."

So, the getMessage() is intended for "advanced users/loging" and the getErrorCode() is intended for getting the corresponding real message (language independent) from the properties files defined on the

 <bean id="messageSource"
        class=" eBundleMessageSource">
        <property name="basename">

so it is more clear for the web tier (on *Controller classes), but how to do with a different tier, lets say in a dos command application that simply invokes the Service Classes (Business Classes) and the errors are catch, how to we get for example access to a simple Junit Test (dos command application) to such error code values.

I gues for testing we should use the method: AbstractDependencyInjectionSpringContextTests.cont extKey() , but I am not sure about that.

Thanks in advance,


Reply With Quote