ErrorCode.java
001 package org.apache.qpid;
002 /*
003  
004  * Licensed to the Apache Software Foundation (ASF) under one
005  * or more contributor license agreements.  See the NOTICE file
006  * distributed with this work for additional information
007  * regarding copyright ownership.  The ASF licenses this file
008  * to you under the Apache License, Version 2.0 (the
009  * "License"); you may not use this file except in compliance
010  * with the License.  You may obtain a copy of the License at
011  
012  *   http://www.apache.org/licenses/LICENSE-2.0
013  
014  * Unless required by applicable law or agreed to in writing,
015  * software distributed under the License is distributed on an
016  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017  * KIND, either express or implied.  See the License for the
018  * specific language governing permissions and limitations
019  * under the License.
020  
021  */
022 
023 
024 public enum ErrorCode
025 {
026     //Qpid specific - for the time being
027     UNDEFINED(1,"undefined",true),
028     MESSAGE_REJECTED(2,"message_rejected",true),
029     CONNECTION_ERROR(3,"connection was closed",true),
030     UNSUPPORTED_PROTOCOL(4"protocol version is unsupported"true),
031 
032     //This might change in the spec, the error class is not applicable
033     NO_ERROR(200,"reply-success",true),
034 
035     //From the spec
036     CONTENT_TOO_LARGE(311,"content-too-large",false),
037     NO_ROUTE(312,"no-route",false),
038     NO_CONSUMERS(313,"content-consumers",false),
039     CONNECTION_FORCED(320,"connection-forced",true),
040     INVALID_PATH(402,"invalid-path",true),
041     ACCESS_REFUSED(403,"access-refused",false),
042     NOT_FOUND(404,"not-found",false),
043     RESOURCE_LOCKED(405,"resource-locked",false),
044     PRE_CONDITION_FAILED(406,"precondition-failed",false),
045 
046     FRAME_ERROR(501,"frame_error",true),
047     SYNTAX_ERROR(502,"syntax_error",true),
048     COMMAND_INVALID(503,"command_invalid",true),
049     SESSION_ERROR(504,"sesion_error",true),
050     NOT_ALLOWED(530,"not_allowed",true),
051     NOT_IMPLEMENTED(540,"not_implemented",true),
052     INTERNAL_ERROR(541,"internal_error",true),
053     INVALID_ARGUMENT(542,"invalid_argument",true);
054 
055     private int _code;
056     private String _desc;
057     private boolean _hardError;
058 
059     private ErrorCode(int code,String desc,boolean hardError)
060     {
061         _code = code;
062         _desc= desc;
063         _hardError = hardError;
064     }
065 
066     public int getCode()
067     {
068         return _code;
069     }
070 
071     public String getDesc()
072     {
073         return _desc;
074     }
075 
076     private boolean isHardError()
077     {
078         return _hardError;
079     }
080 
081     public static ErrorCode get(int code)
082     {
083         switch(code)
084         {
085             case 200 return NO_ERROR;
086             case 311 return CONTENT_TOO_LARGE;
087             case 312 return NO_ROUTE;
088             case 313 return NO_CONSUMERS;
089             case 320 return CONNECTION_FORCED;
090             case 402 return INVALID_PATH;
091             case 403 return ACCESS_REFUSED;
092             case 404 return NOT_FOUND;
093             case 405 return RESOURCE_LOCKED;
094             case 406 return PRE_CONDITION_FAILED;
095             case 501 return FRAME_ERROR;
096             case 502 return SYNTAX_ERROR;
097             case 503 return COMMAND_INVALID;
098             case 504 return SESSION_ERROR;
099             case 530 return NOT_ALLOWED;
100             case 540 return NOT_IMPLEMENTED;
101             case 541 return INTERNAL_ERROR;
102             case 542 return INVALID_ARGUMENT;
103 
104             default return UNDEFINED;
105         }
106     }
107  }
108 
109 /*
110 
111 <constant name="internal-error" value="541" class="hard-error">
112 <doc>
113   The server could not complete the method because of an internal error. The server may require
114   intervention by an operator in order to resume normal operations.
115 </doc>
116 </constant>
117 
118 <constant name="invalid-argument" value="542" class="hard-error">
119 <doc>
120   An invalid or illegal argument was passed to a method, and the operation could not proceed.
121 </doc>
122 </constant>
123 */