diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2008-11-06 09:54:54 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2008-11-06 09:54:54 +0000 |
| commit | d8b43ab738b5602bdda79337057da6b0996273ca (patch) | |
| tree | d1122427227852a0bef31fe256e3e366954e9a2c /qpid/java | |
| parent | 4ab2cb705532e8bf26dde6977fb65e16a3f64588 (diff) | |
| download | qpid-python-d8b43ab738b5602bdda79337057da6b0996273ca.tar.gz | |
QPID-1434 : Add ability to rethrow AMQExceptions
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711818 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
| -rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpid/AMQException.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java index eda532b64e..1cfd7e3134 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java @@ -90,4 +90,34 @@ public class AMQException extends Exception { return true; } + + /** + * Rethrown this exception as a new exception. + * + * Attempt to create a new exception of the same class if they hav the default constructor of: + * {AMQConstant.class, String.class, Throwable.class} + * + * Individual subclasses may override as requried to create a new instance. + * + * @throws AMQException + */ + public void rethrow() throws AMQException + { + Class amqeClass = this.getClass(); + Class<?>[] paramClasses = {AMQConstant.class, String.class, Throwable.class}; + Object[] params = {getErrorCode(), getMessage(), this}; + + AMQException newAMQE; + + try + { + newAMQE = (AMQException) amqeClass.getConstructor(paramClasses).newInstance(params); + } + catch (Exception creationException) + { + newAMQE = new AMQException(getErrorCode(), getMessage(), this); + } + + throw newAMQE; + } } |
