summaryrefslogtreecommitdiff
path: root/qpid/dotnet/client-010/client/client/ErrorCode.cs
blob: 74c3daba4b9f816de79aeb0864568220ab113512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/

using System;

namespace org.apache.qpid.client
{
    public enum QpidErrorCode
    {
        NO_ERROR = 200,
        CONTENT_TOO_LARGE = 311,
        NO_ROUTE = 312,
        NO_CONSUMERS = 313,
        CONNECTION_FORCED = 320,
        INVALID_PATH = 402,
        ACCESS_REFUSED = 403,
        NOT_FOUND = 404,
        RESOURCE_LOCKED = 405,
        PRE_CONDITION_FAILED = 406,
        FRAME_ERROR = 501,
        SYNTAX_ERROR = 502,
        COMMAND_INVALID = 503,
        SESSION_ERROR = 504,
        NOT_ALLOWED = 530,
        NOT_IMPLEMENTED = 540,
        INTERNAL_ERROR = 541,
        INVALID_ARGUMENT = 542,
        UNDEFINED = 1
    }

    public struct ErrorCode
    {
        private int _code;
        private String _desc;
        private readonly bool _hardError;

        public ErrorCode(int code, String desc, bool hardError)
        {
            _code = code;
            _desc = desc;
            _hardError = hardError;
        }

        public int Code
        {
            get { return _code; }
            set { _code = value; }
        }

        public String Description
        {
            get { return _desc; }
            set { _desc = value; }
        }

        public bool ISHardError
        {
            get { return _hardError; }
        }

        public static ErrorCode GetErrorCode(int code)
        {
            switch (code)
            {
                case 200:
                    return
                        new ErrorCode(200, "reply-success", true);
                case 311:
                    return
                        new ErrorCode(311, "content-too-large", false);
                case 312:
                    return
                        new ErrorCode(312, "no-route", false);
                case 313:
                    return
                        new ErrorCode(313, "content-consumers", false);
                case 320:
                    return
                        new ErrorCode(320, "connection-forced", true);
                case 402:
                    return
                        new ErrorCode(402, "invalid-path", true);
                case 403:
                    return
                        new ErrorCode(403, "access-refused", false);
                case 404:
                    return
                        new ErrorCode(404, "not-found", false);
                case 405:
                    return
                        new ErrorCode(405, "resource-locked", false);
                case 406:
                    return
                        new ErrorCode(406, "precondition-failed", false);
                case 501:
                    return
                        new ErrorCode(501, "frame_error", true);
                case 502:
                    return
                        new ErrorCode(502, "syntax_error", true);
                case 503:
                    return
                        new ErrorCode(503, "command_invalid", true);
                case 504:
                    return
                        new ErrorCode(504, "sesion_error", true);
                case 530:
                    return
                        new ErrorCode(530, "not_allowed", true);
                case 540:
                    return
                        new ErrorCode(540, "not_implemented", true);
                case 541:
                    return
                        new ErrorCode(541, "internal_error", true);
                case 542:
                    return
                        new ErrorCode(542, "invalid_argument", true);
                default:
                    return new ErrorCode(1, "undefined", true);
            }
        }
    }
}