Skip to content

Commit c7b1123

Browse files
Example usage of LOG_AND_ABORT
1 parent e5111d6 commit c7b1123

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

infra/util/test/TestLogAndAbort.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TEST_F(LogAndAbortTest, log_and_abort_no_handler_does_nothing)
2727
{
2828
// Manually calling hook to avoid aborting the test
2929
infra::ExecuteLogAndAbortHook("fool of a took");
30-
infra::ExecuteLogAndAbortHook("speak %s to enter", "friend");
30+
infra::ExecuteLogAndAbortHook("speak %s and enter", "friend");
3131
}
3232

3333
TEST_F(LogAndAbortTest, log_and_abort_with_handler_calls_handler)
@@ -39,5 +39,5 @@ TEST_F(LogAndAbortTest, log_and_abort_with_handler_calls_handler)
3939
EXPECT_CALL(listener, LogAndAbortHook(testing::_, testing::_)).Times(1);
4040

4141
// Manually calling hook to avoid aborting the test
42-
infra::ExecuteLogAndAbortHook("speak %s to enter", "friend");
42+
infra::ExecuteLogAndAbortHook("speak %s and enter", "friend");
4343
}

protobuf/echo/EchoErrorPolicy.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "protobuf/echo/EchoErrorPolicy.hpp"
2+
#include "infra/util/LogAndAbort.hpp"
23
#include <cstdlib>
34

45
namespace services
@@ -8,7 +9,7 @@ namespace services
89

910
void EchoErrorPolicyAbortOnMessageFormatError::MessageFormatError() const
1011
{
11-
std::abort();
12+
LOG_AND_ABORT("Echo message format error");
1213
}
1314

1415
void EchoErrorPolicyAbortOnMessageFormatError::ServiceNotFound(uint32_t serviceId) const
@@ -19,11 +20,11 @@ namespace services
1920

2021
void EchoErrorPolicyAbort::ServiceNotFound(uint32_t serviceId) const
2122
{
22-
std::abort();
23+
LOG_AND_ABORT("Echo service not found: %u", serviceId);
2324
}
2425

2526
void EchoErrorPolicyAbort::MethodNotFound(uint32_t serviceId, uint32_t methodId) const
2627
{
27-
std::abort();
28+
LOG_AND_ABORT("Echo method not found: %u %u", serviceId, methodId);
2829
}
2930
}

0 commit comments

Comments
 (0)