Allow additional identifying arguments to be passed to the PersistingUnit for

use when logging failure.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5520 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-11-07 19:12:45 +00:00
parent 2187609696
commit 4ab8689ea9
@@ -21,6 +21,7 @@
package com.threerings.presents.util;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.Invoker;
import com.threerings.presents.client.InvocationService;
@@ -47,6 +48,18 @@ public abstract class PersistingUnit extends Invoker.Unit
super(name);
_listener = listener;
}
/**
* Creates a persisting unit with the supplied name and listener and a set of key/value pairs
* that will be included in the failure message if this unit fails.
*/
public PersistingUnit (String name, InvocationService.InvocationListener listener,
Object... args)
{
super(name);
_listener = listener;
_args = args;
}
/**
* This method is where the unit performs its persistent actions. Any persistence exception
@@ -71,7 +84,11 @@ public abstract class PersistingUnit extends Invoker.Unit
if (error instanceof InvocationException) {
_listener.requestFailed(error.getMessage());
} else {
log.warning("Unit threw an exception", "message", getFailureMessage(), error);
if (_args != null) {
log.warning(getFailureMessage(), ArrayUtil.append(_args, error));
} else {
log.warning(getFailureMessage(), error);
}
_listener.requestFailed(InvocationCodes.INTERNAL_ERROR);
}
}
@@ -126,4 +143,5 @@ public abstract class PersistingUnit extends Invoker.Unit
protected InvocationService.InvocationListener _listener;
protected Exception _error;
protected Object[] _args;
}