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 | 23b0950928a190f439f9cb54dcb6984eb6a47a51 (patch) | |
| tree | 97d3bc5fcdab63c0633ea95dc066a6b8ce447023 /java/common/src | |
| parent | 7f35cab90fd059a5befcb1205748f9f68238bfd8 (diff) | |
| download | qpid-python-23b0950928a190f439f9cb54dcb6984eb6a47a51.tar.gz | |
QPID-1434 : Add ability to rethrow AMQExceptions
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@711818 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
| -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; + } } |
