|
Home > Archive > WebSphere Commerce suite > April 2006 > Error Handling and message display issue
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Error Handling and message display issue
|
|
|
| Hi
I am trying to display custom message in my shopping cart page during clearing shopping cart. The clear cart code is customized and I wanted to display error when the application fails to clear the cart.
here is my sample code:
try{
application code..
}catch (CustomException ce) {
log fatal...
throw new ECApplicationException(
MyMessages._MY_ERROR,
CLASSNAME,
METHODNAME,
ECMessageHelper.generateMsgParms(ce.getMessage(),"param1", "param2")
);
}
Here is MyMessage code:
public static final ECMessage _MY_ERROR =
new ECMessage (ECMessageSeverity.ERROR, ECMessageType.USER, "_MY_ERROR", "MyBundle");
Here is MyBundle.properties:
_MY_ERROR=This is my custom message. {0}, {1}, {2}
At some of the custom ControllerCommands the message is displayed correct on the source jsp but from one of custom taskCommand the message is displayed in a GenericError page and I see following error at the console:
[3/10/06 11:22:04:984 CST] 5e315e31 SystemOut O 2006.03.10 11:22:04.863 ECMessageHelper getCorrectiveActionMessageFromUserBundle
CMN0410E: Failed to retrieve from "Missing reource exception" the message with key "{1}".
How do I make this message display on the shopping cart page instead? I have tried most of permetutions and combinations but no avail. What am I missing?
Commersoul..
| |
|
| I've seen this before and if I remember correctly you must make sure that WC is able to locate the ResourceBundle you've associated. If its a store specific ResourceBundle ensure that you've built the correct path at the time the ECException is thrown.
Also when passing your exception parameters try just using an Object[] array instead of the ECMessageHelper to generate the message params. I'm willing to bet you'll be able to get the results you want by doing the following.
//Build message at runtime, not as a stored message. This is just to test that
//the message is being recognized.
ECMessage ecm = new ECMessage(ECMessageSeverity.ERROR,ECMessageType.USER,"MY_MESSAGE_ID",myResourceBundlePath,classname));
//Now throw the ECApplicationException with runtime Object[]
throw new ECApplicationException(ecm,classname,mn,
new Object[]& #123;myParam1,myParam2,myParam3},false);
//If you want this message logged remove the last parameter
Try it this way and I'll bet your message shows up. I think what happens is that the WC message handler either ignores custom bundles or it fails to find the custom bundle if its store or locale specific, which then causes it to attempt to locate the
SystemMessages. I'm not sure about that, but it seems that something along those lines is taking place.
|
|
|
|
|