admin@glassfish.java.net

Re: exiting decorator when throwing exception

From: Carla Mott <carla.mott_at_oracle.com>
Date: Fri, 17 Sep 2010 08:59:50 -0700

Looking at other code that does something similar I see the same usage.
Are all messages that end up in GenericDeleteCommand printed twice?
Have you forced a failure in the decorator for Cluster? I'll test this
in a bit.

carla

Jennifer Chou wrote:
> Your decorator code looks ok to me. Maybe the GenericDeleteCommand
> needs to handle the message display better.
>
> On 9/17/2010 2:57 PM, Carla Mott wrote:
>> Hi,
>>
>> I have a question about exiting a decorator when you find an error
>> while updating a config element. Specifically when I have to work
>> within a transaction. If I find an error and want to terminate
>> processing (return) I thought I had to throw an exception to return.
>> When I do that it seems that I get the error message twice. What is
>> the proper way to exit and what should the exception message be?
>>
>> code below throws an exception but prints the message twice.
>>
>> my decorator:
>> if (instanceName != null) {
>> final String msg = localStrings.getLocalString(
>> "Node.referencedByInstance",
>> "Node {0} referenced in server
>> instance(s): {1}. Remove instances before removing node."
>> ,child.getName() ,instanceName );
>> throw new TransactionFailure(msg);
>> }
>>
>> }
>>
>> nodeList.remove(child);
>>
>> ends up GenericDeleteCommand:
>>
>> } catch(TransactionFailure e) {
>> String msg =
>> localStrings.getLocalString(GenericCrudCommand.class,
>> "GenericDeleteCommand.transaction_exception",
>> "Exception while deleting the configuration {0}
>> :{1}",
>> child.typeName(), e.getMessage());
>> result.failure(logger, msg, e);
>> }
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>