Made ObjectAccessException a nestable exception; modified

objectAvailable() error dispatching to not incorrectly report a failure to
create an object.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@918 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-02-02 09:42:36 +00:00
parent c6d2529e78
commit 9d9872f606
4 changed files with 47 additions and 22 deletions
@@ -1,5 +1,5 @@
//
// $Id: DEventUtil.java,v 1.3 2001/10/11 04:07:52 mdb Exp $
// $Id: DEventUtil.java,v 1.4 2002/02/02 09:42:36 mdb Exp $
package com.threerings.presents.dobj;
@@ -39,7 +39,7 @@ public class DEventUtil
}
} catch (SecurityException se) {
throw new ObjectAccessException("Reflection error: " + se);
throw new ObjectAccessException("Reflection error", se);
}
// make sure we found a matching method
@@ -1,5 +1,5 @@
//
// $Id: DObject.java,v 1.31 2001/10/12 20:12:48 mdb Exp $
// $Id: DObject.java,v 1.32 2002/02/02 09:42:36 mdb Exp $
package com.threerings.presents.dobj;
@@ -378,8 +378,8 @@ public class DObject
} catch (Exception e) {
String errmsg = "Attribute setting failure [name=" + name +
", value=" + value + ", error=" + e + "].";
throw new ObjectAccessException(errmsg);
", value=" + value + "].";
throw new ObjectAccessException(errmsg, e);
}
}
@@ -396,9 +396,8 @@ public class DObject
return getClass().getField(name).get(this);
} catch (Exception e) {
String errmsg = "Attribute getting failure [name=" + name +
", error=" + e + "].";
throw new ObjectAccessException(errmsg);
String errmsg = "Attribute getting failure [name=" + name + "].";
throw new ObjectAccessException(errmsg, e);
}
}
@@ -1,8 +1,10 @@
//
// $Id: ObjectAccessException.java,v 1.2 2001/10/11 04:07:52 mdb Exp $
// $Id: ObjectAccessException.java,v 1.3 2002/02/02 09:42:36 mdb Exp $
package com.threerings.presents.dobj;
import org.apache.commons.util.exception.NestableException;
/**
* An object access exception is delivered when an object is not
* accessible to a requesting subscriber for some reason or other. For
@@ -10,10 +12,32 @@ package com.threerings.presents.dobj;
* the error. For others, a message string explaining the access failure
* is provided.
*/
public class ObjectAccessException extends Exception
public class ObjectAccessException extends NestableException
{
/**
* Constructs a object access exception with the specified error
* message.
*/
public ObjectAccessException (String message)
{
super(message);
}
/**
* Constructs a object access exception with the specified error
* message and the chained causing event.
*/
public ObjectAccessException (String message, Exception cause)
{
super(message, cause);
}
/**
* Constructs a object access exception with the specified chained
* causing event.
*/
public ObjectAccessException (Exception cause)
{
super(cause);
}
}
@@ -1,5 +1,5 @@
//
// $Id: PresentsDObjectMgr.java,v 1.20 2001/12/04 01:01:54 mdb Exp $
// $Id: PresentsDObjectMgr.java,v 1.21 2002/02/02 09:42:36 mdb Exp $
package com.threerings.presents.server;
@@ -477,15 +477,6 @@ public class PresentsDObjectMgr implements RootDObjectManager
// Log.info("Created object [obj=" + obj + "].");
if (_target != null) {
// add the subscriber to this object's subscriber list
obj.addSubscriber(_target);
// let the target subscriber know that their object is
// available
informObjectAvailable(_target, obj);
}
} catch (Exception e) {
Log.warning("Object creation failure " +
"[class=" + _class.getName() +
@@ -493,10 +484,21 @@ public class PresentsDObjectMgr implements RootDObjectManager
// let the subscriber know shit be fucked
if (_target != null) {
String errmsg = "Object instantiation failed: " + e;
String errmsg = "Object instantiation failed";
_target.requestFailed(
oid, new ObjectAccessException(errmsg));
oid, new ObjectAccessException(errmsg, e));
}
return false;
}
if (_target != null) {
// add the subscriber to this object's subscriber list
obj.addSubscriber(_target);
// let the target subscriber know that their object is
// available
informObjectAvailable(_target, obj);
}
// and return false to ensure that this event is not