| 210 | } |
| 211 | |
| 212 | void 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 | |
| 240 | void APIRequestHandler::onResourceReportAction( |
| 241 | [[maybe_unused]] HTTPServerRequest & request, [[maybe_unused]] HTMLForm & params, HTTPServerResponse & response) |
nothing calls this directly
no test coverage detected