diff options
| author | Robert Greig <rgreig@apache.org> | 2007-04-09 15:26:04 +0000 |
|---|---|---|
| committer | Robert Greig <rgreig@apache.org> | 2007-04-09 15:26:04 +0000 |
| commit | f966c066fc10c1510c244c41958e343c682dd1a1 (patch) | |
| tree | ff0d2818fe3729bb6ebdfcb8d654d17b8599538f /java/common/src | |
| parent | b8b2e032a4a6a6ad796ce6247c581a0498b5c264 (diff) | |
| download | qpid-python-f966c066fc10c1510c244c41958e343c682dd1a1.tar.gz | |
Stopped throwing away exception causes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@526776 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
6 files changed, 68 insertions, 27 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 32c1e76a39..2f04a01f53 100644 --- a/java/common/src/main/java/org/apache/qpid/AMQException.java +++ b/java/common/src/main/java/org/apache/qpid/AMQException.java @@ -22,11 +22,41 @@ package org.apache.qpid; import org.apache.qpid.protocol.AMQConstant; -/** Generic AMQ exception. */ +/** + * AMQException forms the root exception of all exceptions relating to the AMQ protocol. It provides space to associate + * an AMQ error code with the exception, which is a numberic value, with a meaning defined by the protocol. + * + * <p/><table id="crc"><caption>CRC Card</caption> + * <tr><th> Responsibilities <th> Collaborations + * <tr><td> Represents an exception condition associated with an AMQ protocol error code. + * </table> + * + * @todo This exception class is also used as a generic exception throughout Qpid code. This usage may not be strictly + * correct if this is to signify a protocol exception. Should review. + */ public class AMQException extends Exception { + /** Holds the AMQ error code constant associated with this exception. */ private AMQConstant _errorCode; + /** + * Creates an exception with an optional error code, optional message and optional underlying cause. + * + * @param errorCode The error code. May be null if not to be set. + * @param msg The exception message. May be null if not to be set. + * @param t The underlying cause of the exception. May be null if not to be set. + */ + public AMQException(AMQConstant errorCode, String msg, Throwable t) + { + super(((msg == null) ? "" : msg) + ((errorCode == null) ? "" : (" [error code " + errorCode + "]")), t); + _errorCode = errorCode; + } + + /** + * @param message + * + * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead. + */ public AMQException(String message) { super(message); @@ -34,6 +64,12 @@ public class AMQException extends Exception _errorCode = AMQConstant.getConstant(-1); } + /** + * @param msg + * @param t + * + * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead. + */ public AMQException(String msg, Throwable t) { super(msg, t); @@ -41,21 +77,25 @@ public class AMQException extends Exception _errorCode = AMQConstant.getConstant(-1); } - public AMQException(AMQConstant errorCode, String msg, Throwable t) - { - super(msg + " [error code " + errorCode + ']', t); - _errorCode = errorCode; - } - + /** + * @param errorCode + * @param msg + * + * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead. + */ public AMQException(AMQConstant errorCode, String msg) { super(msg + " [error code " + errorCode + ']'); _errorCode = errorCode; } + /** + * Gets the AMQ protocol exception code associated with this exception. + * + * @return The AMQ protocol exception code associated with this exception. + */ public AMQConstant getErrorCode() { return _errorCode; } - } diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java b/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java index 43f888c029..9f36448986 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java @@ -94,7 +94,7 @@ public class AMQDataBlockDecoder if(bodyFactory == null) { - throw new AMQFrameDecodingException("Unsupported frame type: " + type); + throw new AMQFrameDecodingException(null, "Unsupported frame type: " + type, null); } final int channel = in.getUnsignedShort(); @@ -103,8 +103,8 @@ public class AMQDataBlockDecoder // bodySize can be zero if (channel < 0 || bodySize < 0) { - throw new AMQFrameDecodingException("Undecodable frame: type = " + type + " channel = " + channel + - " bodySize = " + bodySize); + throw new AMQFrameDecodingException(null, "Undecodable frame: type = " + type + " channel = " + channel + + " bodySize = " + bodySize, null); } AMQFrame frame = new AMQFrame(in, channel, bodySize, bodyFactory); @@ -113,7 +113,7 @@ public class AMQDataBlockDecoder byte marker = in.get(); if ((marker & 0xFF) != 0xCE) { - throw new AMQFrameDecodingException("End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type); + throw new AMQFrameDecodingException(null, "End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type, null); } return frame; } diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java b/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java index a3d4513240..171da76771 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java @@ -21,16 +21,17 @@ package org.apache.qpid.framing; import org.apache.qpid.AMQException; +import org.apache.qpid.protocol.AMQConstant; public class AMQFrameDecodingException extends AMQException { - public AMQFrameDecodingException(String message) + /*public AMQFrameDecodingException(String message) { super(message); - } + }*/ - public AMQFrameDecodingException(String message, Throwable t) + public AMQFrameDecodingException(AMQConstant errorCode, String message, Throwable t) { - super(message, t); + super(errorCode, message, t); } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java index 8b784fa3f7..008afb490e 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java +++ b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java @@ -341,7 +341,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti } catch (AMQFrameDecodingException e) { - throw new RuntimeException("Error in content header data: " + e); + throw new RuntimeException("Error in content header data: " + e, e); } final int endPos = buffer.position(); @@ -381,7 +381,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti } catch (AMQFrameDecodingException e) { - throw new RuntimeException("Error in content header data: " + e); + throw new RuntimeException("Error in content header data: " + e, e); } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java index 7dac018872..712eb437db 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java +++ b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java @@ -49,7 +49,7 @@ public class ContentHeaderPropertiesFactory } else { - throw new AMQFrameDecodingException("Unsupport content header class id: " + classId); + throw new AMQFrameDecodingException(null, "Unsupport content header class id: " + classId, null); } properties.populatePropertiesFromBuffer(buffer, propertyFlags, size); return properties; diff --git a/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java b/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java index fcd8d47d32..916b476185 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java +++ b/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java @@ -152,31 +152,31 @@ public class VersionSpecificRegistry }
catch (NullPointerException e)
{
- throw new AMQFrameDecodingException("Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
- + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".", e);
}
catch (IndexOutOfBoundsException e)
{
if (classID >= _registry.length)
{
- throw new AMQFrameDecodingException("Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID
- + ".");
+ + ".", e);
}
else
{
- throw new AMQFrameDecodingException("Method " + methodID + " unknown in AMQP version "
+ throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version "
+ _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
- + " method " + methodID + ".");
+ + " method " + methodID + ".", e);
}
}
if (bodyFactory == null)
{
- throw new AMQFrameDecodingException("Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion
- + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".", null);
}
return bodyFactory.newInstance(_protocolMajorVersion, _protocolMinorVersion, classID, methodID, in, size);
|
