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

Method trySendExceptionToClient

src/Server/APIRequestHandler.cpp:212–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212void APIRequestHandler::trySendExceptionToClient(
213 const std::string & exception_msg, int exception_code, [[maybe_unused]] HTTPServerRequest & request, HTTPServerResponse & response)
214{
215 bool auth_fail = exception_code == ErrorCodes::UNKNOWN_USER //
216 || exception_code == ErrorCodes::WRONG_PASSWORD //
217 || exception_code == ErrorCodes::REQUIRED_PASSWORD;
218
219 if (auth_fail)
220 {
221 response.requireAuthentication("ClickHouse server HTTP API");
222 }
223 else
224 {
225 response.setStatusAndReason(exceptionCodeToHTTPStatus(exception_code));
226 }
227
228 if (!response.sent())
229 {
230 Result res(exception_code);
231 res.add("exception", exception_msg);
232 sendResult(res, response);
233 }
234 else
235 {
236 LOG_ERROR(log, "Ocurrs error while sending data due to {}", exception_msg);
237 }
238}
239
240void APIRequestHandler::onResourceReportAction(
241 [[maybe_unused]] HTTPServerRequest & request, [[maybe_unused]] HTMLForm & params, HTTPServerResponse & response)

Callers

nothing calls this directly

Calls 4

requireAuthenticationMethod · 0.80
sentMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected