MCPcopy Create free account
hub / github.com/ByConity/ByConity / exceptionCodeToHTTPStatus

Function exceptionCodeToHTTPStatus

src/Server/HTTPHandler.cpp:155–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155static Poco::Net::HTTPResponse::HTTPStatus exceptionCodeToHTTPStatus(int exception_code)
156{
157 using namespace Poco::Net;
158
159 if (exception_code == ErrorCodes::REQUIRED_PASSWORD)
160 {
161 return HTTPResponse::HTTP_UNAUTHORIZED;
162 }
163 else if (exception_code == ErrorCodes::UNKNOWN_USER ||
164 exception_code == ErrorCodes::WRONG_PASSWORD ||
165 exception_code == ErrorCodes::AUTHENTICATION_FAILED)
166 {
167 return HTTPResponse::HTTP_FORBIDDEN;
168 }
169 else if (exception_code == ErrorCodes::CANNOT_PARSE_TEXT ||
170 exception_code == ErrorCodes::CANNOT_PARSE_ESCAPE_SEQUENCE ||
171 exception_code == ErrorCodes::CANNOT_PARSE_QUOTED_STRING ||
172 exception_code == ErrorCodes::CANNOT_PARSE_DATE ||
173 exception_code == ErrorCodes::CANNOT_PARSE_DATETIME ||
174 exception_code == ErrorCodes::CANNOT_PARSE_NUMBER ||
175 exception_code == ErrorCodes::CANNOT_PARSE_IPV4 ||
176 exception_code == ErrorCodes::CANNOT_PARSE_IPV6 ||
177 exception_code == ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED ||
178 exception_code == ErrorCodes::UNKNOWN_ELEMENT_IN_AST ||
179 exception_code == ErrorCodes::UNKNOWN_TYPE_OF_AST_NODE ||
180 exception_code == ErrorCodes::TOO_DEEP_AST ||
181 exception_code == ErrorCodes::TOO_BIG_AST ||
182 exception_code == ErrorCodes::UNEXPECTED_AST_STRUCTURE ||
183 exception_code == ErrorCodes::SYNTAX_ERROR ||
184 exception_code == ErrorCodes::INCORRECT_DATA ||
185 exception_code == ErrorCodes::TYPE_MISMATCH)
186 {
187 return HTTPResponse::HTTP_BAD_REQUEST;
188 }
189 else if (exception_code == ErrorCodes::UNKNOWN_TABLE ||
190 exception_code == ErrorCodes::UNKNOWN_FUNCTION ||
191 exception_code == ErrorCodes::UNKNOWN_IDENTIFIER ||
192 exception_code == ErrorCodes::UNKNOWN_TYPE ||
193 exception_code == ErrorCodes::UNKNOWN_STORAGE ||
194 exception_code == ErrorCodes::UNKNOWN_DATABASE ||
195 exception_code == ErrorCodes::UNKNOWN_SETTING ||
196 exception_code == ErrorCodes::UNKNOWN_DIRECTION_OF_SORTING ||
197 exception_code == ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION ||
198 exception_code == ErrorCodes::UNKNOWN_FORMAT ||
199 exception_code == ErrorCodes::UNKNOWN_DATABASE_ENGINE ||
200 exception_code == ErrorCodes::UNKNOWN_TYPE_OF_QUERY)
201 {
202 return HTTPResponse::HTTP_NOT_FOUND;
203 }
204 else if (exception_code == ErrorCodes::QUERY_IS_TOO_LARGE)
205 {
206 return HTTPResponse::HTTP_REQUESTENTITYTOOLARGE;
207 }
208 else if (exception_code == ErrorCodes::NOT_IMPLEMENTED)
209 {
210 return HTTPResponse::HTTP_NOT_IMPLEMENTED;
211 }
212 else if (exception_code == ErrorCodes::SOCKET_TIMEOUT ||

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected