Mercurial > hg > orthanc
annotate OrthancCppClient/HttpException.cpp @ 291:4d7469f72a0b
embedding of dicom dictionaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Dec 2012 15:15:48 +0100 |
parents | 77aec9be0a51 |
children | e3a40c7846b8 |
rev | line source |
---|---|
0 | 1 /** |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
0 | 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 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
30 namespace Orthanc |
0 | 31 { |
32 const char* HttpException::What() const | |
33 { | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
34 if (status_ == Orthanc_HttpStatus_None) |
0 | 35 { |
36 return custom_.c_str(); | |
37 } | |
38 else | |
39 { | |
40 return GetDescription(status_); | |
41 } | |
42 } | |
43 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
44 const char* HttpException::GetDescription(Orthanc_HttpStatus status) |
0 | 45 { |
46 switch (status) | |
47 { | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
48 case Orthanc_HttpStatus_100_Continue: |
0 | 49 return "Continue"; |
50 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
51 case Orthanc_HttpStatus_101_SwitchingProtocols: |
0 | 52 return "Switching Protocols"; |
53 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
54 case Orthanc_HttpStatus_102_Processing: |
0 | 55 return "Processing"; |
56 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
57 case Orthanc_HttpStatus_200_Ok: |
0 | 58 return "OK"; |
59 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
60 case Orthanc_HttpStatus_201_Created: |
0 | 61 return "Created"; |
62 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
63 case Orthanc_HttpStatus_202_Accepted: |
0 | 64 return "Accepted"; |
65 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
66 case Orthanc_HttpStatus_203_NonAuthoritativeInformation: |
0 | 67 return "Non-Authoritative Information"; |
68 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
69 case Orthanc_HttpStatus_204_NoContent: |
0 | 70 return "No Content"; |
71 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
72 case Orthanc_HttpStatus_205_ResetContent: |
0 | 73 return "Reset Content"; |
74 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
75 case Orthanc_HttpStatus_206_PartialContent: |
0 | 76 return "Partial Content"; |
77 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
78 case Orthanc_HttpStatus_207_MultiStatus: |
0 | 79 return "Multi-Status"; |
80 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
81 case Orthanc_HttpStatus_208_AlreadyReported: |
0 | 82 return "Already Reported"; |
83 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
84 case Orthanc_HttpStatus_226_IMUsed: |
0 | 85 return "IM Used"; |
86 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
87 case Orthanc_HttpStatus_300_MultipleChoices: |
0 | 88 return "Multiple Choices"; |
89 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
90 case Orthanc_HttpStatus_301_MovedPermanently: |
0 | 91 return "Moved Permanently"; |
92 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
93 case Orthanc_HttpStatus_302_Found: |
0 | 94 return "Found"; |
95 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
96 case Orthanc_HttpStatus_303_SeeOther: |
0 | 97 return "See Other"; |
98 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
99 case Orthanc_HttpStatus_304_NotModified: |
0 | 100 return "Not Modified"; |
101 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
102 case Orthanc_HttpStatus_305_UseProxy: |
0 | 103 return "Use Proxy"; |
104 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
105 case Orthanc_HttpStatus_307_TemporaryRedirect: |
0 | 106 return "Temporary Redirect"; |
107 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
108 case Orthanc_HttpStatus_400_BadRequest: |
0 | 109 return "Bad Request"; |
110 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
111 case Orthanc_HttpStatus_401_Unauthorized: |
0 | 112 return "Unauthorized"; |
113 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
114 case Orthanc_HttpStatus_402_PaymentRequired: |
0 | 115 return "Payment Required"; |
116 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
117 case Orthanc_HttpStatus_403_Forbidden: |
0 | 118 return "Forbidden"; |
119 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
120 case Orthanc_HttpStatus_404_NotFound: |
0 | 121 return "Not Found"; |
122 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
123 case Orthanc_HttpStatus_405_MethodNotAllowed: |
0 | 124 return "Method Not Allowed"; |
125 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
126 case Orthanc_HttpStatus_406_NotAcceptable: |
0 | 127 return "Not Acceptable"; |
128 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
129 case Orthanc_HttpStatus_407_ProxyAuthenticationRequired: |
0 | 130 return "Proxy Authentication Required"; |
131 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
132 case Orthanc_HttpStatus_408_RequestTimeout: |
0 | 133 return "Request Timeout"; |
134 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
135 case Orthanc_HttpStatus_409_Conflict: |
0 | 136 return "Conflict"; |
137 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
138 case Orthanc_HttpStatus_410_Gone: |
0 | 139 return "Gone"; |
140 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
141 case Orthanc_HttpStatus_411_LengthRequired: |
0 | 142 return "Length Required"; |
143 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
144 case Orthanc_HttpStatus_412_PreconditionFailed: |
0 | 145 return "Precondition Failed"; |
146 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
147 case Orthanc_HttpStatus_413_RequestEntityTooLarge: |
0 | 148 return "Request Entity Too Large"; |
149 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
150 case Orthanc_HttpStatus_414_RequestUriTooLong: |
0 | 151 return "Request-URI Too Long"; |
152 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
153 case Orthanc_HttpStatus_415_UnsupportedMediaType: |
0 | 154 return "Unsupported Media Type"; |
155 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
156 case Orthanc_HttpStatus_416_RequestedRangeNotSatisfiable: |
0 | 157 return "Requested Range Not Satisfiable"; |
158 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
159 case Orthanc_HttpStatus_417_ExpectationFailed: |
0 | 160 return "Expectation Failed"; |
161 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
162 case Orthanc_HttpStatus_422_UnprocessableEntity: |
0 | 163 return "Unprocessable Entity"; |
164 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
165 case Orthanc_HttpStatus_423_Locked: |
0 | 166 return "Locked"; |
167 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
168 case Orthanc_HttpStatus_424_FailedDependency: |
0 | 169 return "Failed Dependency"; |
170 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
171 case Orthanc_HttpStatus_426_UpgradeRequired: |
0 | 172 return "Upgrade Required"; |
173 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
174 case Orthanc_HttpStatus_500_InternalServerError: |
0 | 175 return "Internal Server Error"; |
176 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
177 case Orthanc_HttpStatus_501_NotImplemented: |
0 | 178 return "Not Implemented"; |
179 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
180 case Orthanc_HttpStatus_502_BadGateway: |
0 | 181 return "Bad Gateway"; |
182 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
183 case Orthanc_HttpStatus_503_ServiceUnavailable: |
0 | 184 return "Service Unavailable"; |
185 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
186 case Orthanc_HttpStatus_504_GatewayTimeout: |
0 | 187 return "Gateway Timeout"; |
188 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
189 case Orthanc_HttpStatus_505_HttpVersionNotSupported: |
0 | 190 return "HTTP Version Not Supported"; |
191 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
192 case Orthanc_HttpStatus_506_VariantAlsoNegotiates: |
0 | 193 return "Variant Also Negotiates"; |
194 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
195 case Orthanc_HttpStatus_507_InsufficientStorage: |
0 | 196 return "Insufficient Storage"; |
197 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
198 case Orthanc_HttpStatus_509_BandwidthLimitExceeded: |
0 | 199 return "Bandwidth Limit Exceeded"; |
200 | |
60
77aec9be0a51
renaming of cppclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
57
diff
changeset
|
201 case Orthanc_HttpStatus_510_NotExtended: |
0 | 202 return "Not Extended"; |
203 | |
204 default: | |
205 throw HttpException("Unknown HTTP status"); | |
206 } | |
207 } | |
208 } |