diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2007-08-13 23:05:11 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2007-08-13 23:05:11 +0000 |
| commit | 6840763b78d2bc42581b5ecd3536f6195e852a2d (patch) | |
| tree | d4a6d44d88c2396c117c8e64e9e6c6cc00a3213d /java/common/src | |
| parent | b9a3aaab3504ec3cc832f1ee4d0c2266372116f5 (diff) | |
| download | qpid-python-6840763b78d2bc42581b5ecd3536f6195e852a2d.tar.gz | |
added error code support
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@565561 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
5 files changed, 110 insertions, 13 deletions
diff --git a/java/common/src/main/grammar/SelectorParser.jj b/java/common/src/main/grammar/SelectorParser.jj index 3eac164a6d..2dca11748e 100644 --- a/java/common/src/main/grammar/SelectorParser.jj +++ b/java/common/src/main/grammar/SelectorParser.jj @@ -94,7 +94,7 @@ public class SelectorParser { return this.JmsSelector();
}
catch (Throwable e) {
- throw new QpidException(sql,"filter error",e);
+ throw new QpidException(sql,null,e);
}
}
diff --git a/java/common/src/main/java/org/apache/qpidity/ErrorCode.java b/java/common/src/main/java/org/apache/qpidity/ErrorCode.java new file mode 100644 index 0000000000..75f9f00622 --- /dev/null +++ b/java/common/src/main/java/org/apache/qpidity/ErrorCode.java @@ -0,0 +1,101 @@ +package org.apache.qpidity; + +public enum ErrorCode +{ + //Qpid specific - for the time being + UNDEFINED(1,"undefined",true), + MESSAGE_REJECTED(1,"message_rejected",true), + + //This might change in the spec, the error class is not applicable + NO_ERROR(200,"reply-success",true), + + //From the spec + CONTENT_TOO_LARGE(311,"content-too-large",false), + NO_ROUTE(312,"no-route",false), + NO_CONSUMERS(313,"content-consumers",false), + CONNECTION_FORCED(320,"connection-forced",true), + INVALID_PATH(402,"invalid-path",true), + ACCESS_REFUSED(403,"access-refused",false), + NOT_FOUND(404,"not-found",false), + RESOURCE_LOCKED(405,"resource-locked",false), + PRE_CONDITION_FAILED(406,"precondition-failed",false), + + FRAME_ERROR(501,"frame_error",true), + SYNTAX_ERROR(502,"syntax_error",true), + COMMAND_INVALID(503,"command_invalid",true), + SESSION_ERROR(504,"sesion_error",true), + NOT_ALLOWED(530,"not_allowed",true), + NOT_IMPLEMENTED(540,"not_implemented",true), + INTERNAL_ERROR(541,"internal_error",true), + INVALID_ARGUMENT(542,"invalid_argument",true); + + private int _code; + private String _desc; + private boolean _hardError; + + private ErrorCode(int code,String desc,boolean hardError) + { + _code = code; + _desc= desc; + _hardError = hardError; + } + + public int getCode() + { + return _code; + } + + public String getDesc() + { + return _desc; + } + + private boolean isHardError() + { + return _hardError; + } + + public static ErrorCode get(int code) + { + switch(code) + { + case 200 : return NO_ERROR; + case 311 : return CONTENT_TOO_LARGE; + case 312 : return NO_ROUTE; + case 313 : return NO_CONSUMERS; + case 320 : return CONNECTION_FORCED; + case 402 : return INVALID_PATH; + case 403 : return ACCESS_REFUSED; + case 404 : return NOT_FOUND; + case 405 : return RESOURCE_LOCKED; + case 406 : return PRE_CONDITION_FAILED; + case 501 : return FRAME_ERROR; + case 502 : return SYNTAX_ERROR; + case 503 : return COMMAND_INVALID; + case 504 : return SESSION_ERROR; + case 530 : return NOT_ALLOWED; + case 540 : return NOT_IMPLEMENTED; + case 541 : return INTERNAL_ERROR; + case 542 : return INVALID_ARGUMENT; + + default : return UNDEFINED; + } + } + +} + +/* + +<constant name="internal-error" value="541" class="hard-error"> +<doc> + The server could not complete the method because of an internal error. The server may require + intervention by an operator in order to resume normal operations. +</doc> +</constant> + +<constant name="invalid-argument" value="542" class="hard-error"> +<doc> + An invalid or illegal argument was passed to a method, and the operation could not proceed. +</doc> +</constant> +*/
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpidity/QpidException.java b/java/common/src/main/java/org/apache/qpidity/QpidException.java index 5b3671cebd..81e9145282 100644 --- a/java/common/src/main/java/org/apache/qpidity/QpidException.java +++ b/java/common/src/main/java/org/apache/qpidity/QpidException.java @@ -17,17 +17,12 @@ */ package org.apache.qpidity; -/** - * Created by Arnaud Simon - * Date: 20-Jul-2007 - * Time: 10:56:55 - */ public class QpidException extends Exception { /** * AMQP error code */ - private int _errorCode; + private ErrorCode _errorCode; /** * Constructor for a Qpid Exception. @@ -38,24 +33,24 @@ public class QpidException extends Exception * @param cause The linked Execption. * * */ - public QpidException(String message, int errorCode, Throwable cause) + public QpidException(String message, ErrorCode errorCode, Throwable cause) { super(message, cause); _errorCode = errorCode; } - //hack to get rid of a compile error from a generated class + /*hack to get rid of a compile error from a generated class public QpidException(String message, String errorCode, Throwable cause) { - } + }*/ /** * Get this execption error code. * * @return This exception error code. */ - public int getErrorCode() + public ErrorCode getErrorCode() { return _errorCode; } diff --git a/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java b/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java index 474e2f7e8f..d0b3272dec 100644 --- a/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java +++ b/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java @@ -64,7 +64,7 @@ public class SecurityHelper } catch (Exception e) { - throw new QpidException("Unable to create callback handler: " + e,0, e.getCause()); + throw new QpidException("Unable to create callback handler: " + e,ErrorCode.UNDEFINED, e.getCause()); } } diff --git a/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java b/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java index ac3888d5bb..d52dfacfa3 100644 --- a/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java +++ b/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java @@ -18,6 +18,7 @@ package org.apache.qpidity.filter; import org.slf4j.LoggerFactory; +import org.apache.qpidity.ErrorCode; import org.apache.qpidity.QpidException; import javax.jms.Message; @@ -56,7 +57,7 @@ public class PropertyExpression implements Expression } catch (Exception e) { - throw new QpidException("cannot evaluate property ", 0, e); + throw new QpidException("cannot evaluate property ", ErrorCode.UNDEFINED, e); } } return result; |
