Mercurial > hg > orthanc
comparison OrthancCppClient/HttpException.cpp @ 474:a9693dc7089c
move tostring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Jul 2013 17:25:53 +0200 |
parents | c9a5d72f8481 |
children |
comparison
equal
deleted
inserted
replaced
473:c9a5d72f8481 | 474:a9693dc7089c |
---|---|
25 **/ | 25 **/ |
26 | 26 |
27 | 27 |
28 #include "HttpException.h" | 28 #include "HttpException.h" |
29 | 29 |
30 #include "../Core/Toolbox.h" | |
31 | |
30 namespace Orthanc | 32 namespace Orthanc |
31 { | 33 { |
32 const char* HttpException::What() const | 34 const char* HttpException::What() const |
33 { | 35 { |
34 if (status_ == HttpStatus_None) | 36 if (status_ == HttpStatus_None) |
35 { | 37 { |
36 return custom_.c_str(); | 38 return custom_.c_str(); |
37 } | 39 } |
38 else | 40 else |
39 { | 41 { |
40 return GetDescription(status_); | 42 return Toolbox::ToString(status_); |
41 } | |
42 } | |
43 | |
44 const char* HttpException::GetDescription(HttpStatus status) | |
45 { | |
46 switch (status) | |
47 { | |
48 case HttpStatus_100_Continue: | |
49 return "Continue"; | |
50 | |
51 case HttpStatus_101_SwitchingProtocols: | |
52 return "Switching Protocols"; | |
53 | |
54 case HttpStatus_102_Processing: | |
55 return "Processing"; | |
56 | |
57 case HttpStatus_200_Ok: | |
58 return "OK"; | |
59 | |
60 case HttpStatus_201_Created: | |
61 return "Created"; | |
62 | |
63 case HttpStatus_202_Accepted: | |
64 return "Accepted"; | |
65 | |
66 case HttpStatus_203_NonAuthoritativeInformation: | |
67 return "Non-Authoritative Information"; | |
68 | |
69 case HttpStatus_204_NoContent: | |
70 return "No Content"; | |
71 | |
72 case HttpStatus_205_ResetContent: | |
73 return "Reset Content"; | |
74 | |
75 case HttpStatus_206_PartialContent: | |
76 return "Partial Content"; | |
77 | |
78 case HttpStatus_207_MultiStatus: | |
79 return "Multi-Status"; | |
80 | |
81 case HttpStatus_208_AlreadyReported: | |
82 return "Already Reported"; | |
83 | |
84 case HttpStatus_226_IMUsed: | |
85 return "IM Used"; | |
86 | |
87 case HttpStatus_300_MultipleChoices: | |
88 return "Multiple Choices"; | |
89 | |
90 case HttpStatus_301_MovedPermanently: | |
91 return "Moved Permanently"; | |
92 | |
93 case HttpStatus_302_Found: | |
94 return "Found"; | |
95 | |
96 case HttpStatus_303_SeeOther: | |
97 return "See Other"; | |
98 | |
99 case HttpStatus_304_NotModified: | |
100 return "Not Modified"; | |
101 | |
102 case HttpStatus_305_UseProxy: | |
103 return "Use Proxy"; | |
104 | |
105 case HttpStatus_307_TemporaryRedirect: | |
106 return "Temporary Redirect"; | |
107 | |
108 case HttpStatus_400_BadRequest: | |
109 return "Bad Request"; | |
110 | |
111 case HttpStatus_401_Unauthorized: | |
112 return "Unauthorized"; | |
113 | |
114 case HttpStatus_402_PaymentRequired: | |
115 return "Payment Required"; | |
116 | |
117 case HttpStatus_403_Forbidden: | |
118 return "Forbidden"; | |
119 | |
120 case HttpStatus_404_NotFound: | |
121 return "Not Found"; | |
122 | |
123 case HttpStatus_405_MethodNotAllowed: | |
124 return "Method Not Allowed"; | |
125 | |
126 case HttpStatus_406_NotAcceptable: | |
127 return "Not Acceptable"; | |
128 | |
129 case HttpStatus_407_ProxyAuthenticationRequired: | |
130 return "Proxy Authentication Required"; | |
131 | |
132 case HttpStatus_408_RequestTimeout: | |
133 return "Request Timeout"; | |
134 | |
135 case HttpStatus_409_Conflict: | |
136 return "Conflict"; | |
137 | |
138 case HttpStatus_410_Gone: | |
139 return "Gone"; | |
140 | |
141 case HttpStatus_411_LengthRequired: | |
142 return "Length Required"; | |
143 | |
144 case HttpStatus_412_PreconditionFailed: | |
145 return "Precondition Failed"; | |
146 | |
147 case HttpStatus_413_RequestEntityTooLarge: | |
148 return "Request Entity Too Large"; | |
149 | |
150 case HttpStatus_414_RequestUriTooLong: | |
151 return "Request-URI Too Long"; | |
152 | |
153 case HttpStatus_415_UnsupportedMediaType: | |
154 return "Unsupported Media Type"; | |
155 | |
156 case HttpStatus_416_RequestedRangeNotSatisfiable: | |
157 return "Requested Range Not Satisfiable"; | |
158 | |
159 case HttpStatus_417_ExpectationFailed: | |
160 return "Expectation Failed"; | |
161 | |
162 case HttpStatus_422_UnprocessableEntity: | |
163 return "Unprocessable Entity"; | |
164 | |
165 case HttpStatus_423_Locked: | |
166 return "Locked"; | |
167 | |
168 case HttpStatus_424_FailedDependency: | |
169 return "Failed Dependency"; | |
170 | |
171 case HttpStatus_426_UpgradeRequired: | |
172 return "Upgrade Required"; | |
173 | |
174 case HttpStatus_500_InternalServerError: | |
175 return "Internal Server Error"; | |
176 | |
177 case HttpStatus_501_NotImplemented: | |
178 return "Not Implemented"; | |
179 | |
180 case HttpStatus_502_BadGateway: | |
181 return "Bad Gateway"; | |
182 | |
183 case HttpStatus_503_ServiceUnavailable: | |
184 return "Service Unavailable"; | |
185 | |
186 case HttpStatus_504_GatewayTimeout: | |
187 return "Gateway Timeout"; | |
188 | |
189 case HttpStatus_505_HttpVersionNotSupported: | |
190 return "HTTP Version Not Supported"; | |
191 | |
192 case HttpStatus_506_VariantAlsoNegotiates: | |
193 return "Variant Also Negotiates"; | |
194 | |
195 case HttpStatus_507_InsufficientStorage: | |
196 return "Insufficient Storage"; | |
197 | |
198 case HttpStatus_509_BandwidthLimitExceeded: | |
199 return "Bandwidth Limit Exceeded"; | |
200 | |
201 case HttpStatus_510_NotExtended: | |
202 return "Not Extended"; | |
203 | |
204 default: | |
205 throw HttpException("Unknown HTTP status"); | |
206 } | 43 } |
207 } | 44 } |
208 } | 45 } |