Skip to content

Commit c3d949e

Browse files
committed
fix server: log deadline propagation exceptions with WARNING, not ERROR
36a4d824c7df9a9ea3c0ce755b32b34e3154b939
1 parent 575fe16 commit c3d949e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

core/include/userver/server/handlers/http_handler_base.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ class HttpHandlerBase : public HandlerBase {
111111
const std::exception& ex) const;
112112

113113
/// Helper function to log an unknown exception
114-
void LogUnknownException(const std::exception& ex) const;
114+
void LogUnknownException(
115+
const std::exception& ex,
116+
std::optional<logging::Level> log_level_override = {}) const;
115117

116118
/// Returns the default log level for the handler
117119
const std::optional<logging::Level>& GetLogLevel() const;

core/src/server/handlers/http_handler_base.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,15 @@ void HttpHandlerBase::HandleUnknownException(const http::HttpRequest& request,
444444
}
445445
}
446446

447-
void HttpHandlerBase::LogUnknownException(const std::exception& ex) const {
447+
void HttpHandlerBase::LogUnknownException(
448+
const std::exception& ex, std::optional<logging::Level> log_level) const {
448449
if (engine::current_task::ShouldCancel()) {
449-
LOG_WARNING() << "request task cancelled, exception in '" << HandlerName()
450-
<< "' handler: " << ex;
450+
LOG(log_level.value_or(logging::Level::kWarning))
451+
<< "request task cancelled, exception in '" << HandlerName()
452+
<< "' handler: " << ex;
451453
} else {
452-
LOG_ERROR() << "exception in '" << HandlerName() << "' handler: " << ex;
454+
LOG(log_level.value_or(logging::Level::kError))
455+
<< "exception in '" << HandlerName() << "' handler: " << ex;
453456
}
454457
}
455458

core/src/server/middlewares/deadline_propagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void DeadlinePropagation::HandleRequest(
114114
if (dp_scope.shared_dp_context.IsCancelledByDeadline()) {
115115
// No matter what the error is we're setting our response, log and swallow
116116
// the exception.
117-
handler_.LogUnknownException(ex);
117+
handler_.LogUnknownException(ex, logging::Level::kWarning);
118118
return;
119119
} else {
120120
// Let it fly further, not our problem.

0 commit comments

Comments
 (0)