comparison PalanthirCppClient/HttpException.cpp @ 45:33d67e1ab173

r
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Sep 2012 13:24:59 +0200
parents PalantirCppClient/HttpException.cpp@9be852ad33d2
children a15e90e5d6fc
comparison
equal deleted inserted replaced
43:9be852ad33d2 45:33d67e1ab173
1 /**
2 * Palantir - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use, copy,
10 * modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 **/
26
27
28 #include "HttpException.h"
29
30 namespace Palantir
31 {
32 const char* HttpException::What() const
33 {
34 if (status_ == Palantir_HttpStatus_None)
35 {
36 return custom_.c_str();
37 }
38 else
39 {
40 return GetDescription(status_);
41 }
42 }
43
44 const char* HttpException::GetDescription(Palantir_HttpStatus status)
45 {
46 switch (status)
47 {
48 case Palantir_HttpStatus_100_Continue:
49 return "Continue";
50
51 case Palantir_HttpStatus_101_SwitchingProtocols:
52 return "Switching Protocols";
53
54 case Palantir_HttpStatus_102_Processing:
55 return "Processing";
56
57 case Palantir_HttpStatus_200_Ok:
58 return "OK";
59
60 case Palantir_HttpStatus_201_Created:
61 return "Created";
62
63 case Palantir_HttpStatus_202_Accepted:
64 return "Accepted";
65
66 case Palantir_HttpStatus_203_NonAuthoritativeInformation:
67 return "Non-Authoritative Information";
68
69 case Palantir_HttpStatus_204_NoContent:
70 return "No Content";
71
72 case Palantir_HttpStatus_205_ResetContent:
73 return "Reset Content";
74
75 case Palantir_HttpStatus_206_PartialContent:
76 return "Partial Content";
77
78 case Palantir_HttpStatus_207_MultiStatus:
79 return "Multi-Status";
80
81 case Palantir_HttpStatus_208_AlreadyReported:
82 return "Already Reported";
83
84 case Palantir_HttpStatus_226_IMUsed:
85 return "IM Used";
86
87 case Palantir_HttpStatus_300_MultipleChoices:
88 return "Multiple Choices";
89
90 case Palantir_HttpStatus_301_MovedPermanently:
91 return "Moved Permanently";
92
93 case Palantir_HttpStatus_302_Found:
94 return "Found";
95
96 case Palantir_HttpStatus_303_SeeOther:
97 return "See Other";
98
99 case Palantir_HttpStatus_304_NotModified:
100 return "Not Modified";
101
102 case Palantir_HttpStatus_305_UseProxy:
103 return "Use Proxy";
104
105 case Palantir_HttpStatus_307_TemporaryRedirect:
106 return "Temporary Redirect";
107
108 case Palantir_HttpStatus_400_BadRequest:
109 return "Bad Request";
110
111 case Palantir_HttpStatus_401_Unauthorized:
112 return "Unauthorized";
113
114 case Palantir_HttpStatus_402_PaymentRequired:
115 return "Payment Required";
116
117 case Palantir_HttpStatus_403_Forbidden:
118 return "Forbidden";
119
120 case Palantir_HttpStatus_404_NotFound:
121 return "Not Found";
122
123 case Palantir_HttpStatus_405_MethodNotAllowed:
124 return "Method Not Allowed";
125
126 case Palantir_HttpStatus_406_NotAcceptable:
127 return "Not Acceptable";
128
129 case Palantir_HttpStatus_407_ProxyAuthenticationRequired:
130 return "Proxy Authentication Required";
131
132 case Palantir_HttpStatus_408_RequestTimeout:
133 return "Request Timeout";
134
135 case Palantir_HttpStatus_409_Conflict:
136 return "Conflict";
137
138 case Palantir_HttpStatus_410_Gone:
139 return "Gone";
140
141 case Palantir_HttpStatus_411_LengthRequired:
142 return "Length Required";
143
144 case Palantir_HttpStatus_412_PreconditionFailed:
145 return "Precondition Failed";
146
147 case Palantir_HttpStatus_413_RequestEntityTooLarge:
148 return "Request Entity Too Large";
149
150 case Palantir_HttpStatus_414_RequestUriTooLong:
151 return "Request-URI Too Long";
152
153 case Palantir_HttpStatus_415_UnsupportedMediaType:
154 return "Unsupported Media Type";
155
156 case Palantir_HttpStatus_416_RequestedRangeNotSatisfiable:
157 return "Requested Range Not Satisfiable";
158
159 case Palantir_HttpStatus_417_ExpectationFailed:
160 return "Expectation Failed";
161
162 case Palantir_HttpStatus_422_UnprocessableEntity:
163 return "Unprocessable Entity";
164
165 case Palantir_HttpStatus_423_Locked:
166 return "Locked";
167
168 case Palantir_HttpStatus_424_FailedDependency:
169 return "Failed Dependency";
170
171 case Palantir_HttpStatus_426_UpgradeRequired:
172 return "Upgrade Required";
173
174 case Palantir_HttpStatus_500_InternalServerError:
175 return "Internal Server Error";
176
177 case Palantir_HttpStatus_501_NotImplemented:
178 return "Not Implemented";
179
180 case Palantir_HttpStatus_502_BadGateway:
181 return "Bad Gateway";
182
183 case Palantir_HttpStatus_503_ServiceUnavailable:
184 return "Service Unavailable";
185
186 case Palantir_HttpStatus_504_GatewayTimeout:
187 return "Gateway Timeout";
188
189 case Palantir_HttpStatus_505_HttpVersionNotSupported:
190 return "HTTP Version Not Supported";
191
192 case Palantir_HttpStatus_506_VariantAlsoNegotiates:
193 return "Variant Also Negotiates";
194
195 case Palantir_HttpStatus_507_InsufficientStorage:
196 return "Insufficient Storage";
197
198 case Palantir_HttpStatus_509_BandwidthLimitExceeded:
199 return "Bandwidth Limit Exceeded";
200
201 case Palantir_HttpStatus_510_NotExtended:
202 return "Not Extended";
203
204 default:
205 throw HttpException("Unknown HTTP status");
206 }
207 }
208 }