diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/AMQException.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/AMQException.java b/java/common/src/main/java/org/apache/qpid/AMQException.java index eda532b64e..1cfd7e3134 100644 --- a/java/common/src/main/java/org/apache/qpid/AMQException.java +++ b/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; + } } |
