Skip to content

Commit 458337d

Browse files
authored
Merge pull request #701 from elbeno/better-callback-failure
2 parents 494e03f + 5dfd509 commit 458337d

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

include/msg/detail/indexed_handler_common.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ struct indexed_handler : handler_interface<MsgBase, ExtraCallbackArgs...> {
5656
std::logical_or{}, false, callback_candidates);
5757

5858
if (not handled) {
59-
CIB_ERROR("None of the registered callbacks claimed this message.");
59+
CIB_ERROR(
60+
"None of the registered callbacks ({}) claimed this message.",
61+
sc::uint_<stdx::tuple_size_v<Callbacks>>);
6062
}
6163
return handled;
6264
}

include/msg/handler.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <log/log.hpp>
44
#include <msg/handler_interface.hpp>
5+
#include <sc/fwd.hpp>
56

67
#include <stdx/tuple_algorithms.hpp>
78

@@ -27,7 +28,9 @@ struct handler : handler_interface<MsgBase, ExtraCallbackArgs...> {
2728
},
2829
callbacks);
2930
if (!found_valid_callback) {
30-
CIB_ERROR("None of the registered callbacks claimed this message:");
31+
CIB_ERROR(
32+
"None of the registered callbacks ({}) claimed this message:",
33+
sc::uint_<stdx::tuple_size_v<Callbacks>>);
3134
stdx::for_each([&](auto &callback) { callback.log_mismatch(msg); },
3235
callbacks);
3336
}

test/msg/handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ TEST_CASE("log mismatch when no match", "[handler]") {
8787
CHECK(not handler.handle(msg));
8888
CAPTURE(log_buffer);
8989
CHECK(log_buffer.find(
90-
"None of the registered callbacks claimed this message") !=
90+
"None of the registered callbacks (0) claimed this message") !=
9191
std::string::npos);
9292
}
9393

test/msg/handler_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ TEST_CASE("match output failure", "[handler_builder]") {
111111

112112
CAPTURE(log_buffer);
113113
CHECK(log_buffer.find(
114-
"None of the registered callbacks claimed this message") !=
114+
"None of the registered callbacks (1) claimed this message") !=
115115
std::string::npos);
116116
CHECK(log_buffer.find("cb") != std::string::npos);
117117
CHECK(log_buffer.find("id (0x81) == 0x80") != std::string::npos);

test/msg/indexed_builder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ TEST_CASE("match output failure", "[indexed_builder]") {
113113

114114
CHECK(not cib::service<test_service>->handle(
115115
test_msg_t{"test_id_field"_field = 0x81}));
116+
CAPTURE(log_buffer);
116117
CHECK(log_buffer.find(
117-
"None of the registered callbacks claimed this message") !=
118+
"None of the registered callbacks (1) claimed this message") !=
118119
std::string::npos);
119120
}
120121

0 commit comments

Comments
 (0)