From 4ab8689ea9c11f126df19986e4074b66a11efe0b Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 7 Nov 2008 19:12:45 +0000 Subject: [PATCH] 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 --- .../presents/util/PersistingUnit.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/presents/util/PersistingUnit.java b/src/java/com/threerings/presents/util/PersistingUnit.java index f36aa6593..b36f89853 100644 --- a/src/java/com/threerings/presents/util/PersistingUnit.java +++ b/src/java/com/threerings/presents/util/PersistingUnit.java @@ -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; }