performCallback: Don't return errors
Just because a callback throws an error doesn't mean that we want it to
stop source processing.
Change-Id: Ifcd5f61b3423033f720b1e683b56aa49570e6581
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/sdeventplus/internal/utils.hpp b/src/sdeventplus/internal/utils.hpp
index 9d612e5..c078ed6 100644
--- a/src/sdeventplus/internal/utils.hpp
+++ b/src/sdeventplus/internal/utils.hpp
@@ -1,6 +1,5 @@
#pragma once
-#include <cerrno>
#include <chrono>
#include <cstdio>
#include <exception>
@@ -30,23 +29,16 @@
try
{
std::invoke(std::forward<Args>(args)...);
- return 0;
- }
- catch (const std::system_error& e)
- {
- fprintf(stderr, "sdeventplus: %s: %s\n", name, e.what());
- return -e.code().value();
}
catch (const std::exception& e)
{
fprintf(stderr, "sdeventplus: %s: %s\n", name, e.what());
- return -ENOSYS;
}
catch (...)
{
fprintf(stderr, "sdeventplus: %s: Unknown error\n", name);
- return -ENOSYS;
}
+ return 0;
}
/** @brief Constructs an SdEventError for stdplus cexec
diff --git a/test/internal/utils.cpp b/test/internal/utils.cpp
index 8f5d75c..3836c57 100644
--- a/test/internal/utils.cpp
+++ b/test/internal/utils.cpp
@@ -34,21 +34,21 @@
TEST(UtilsTest, SetPrepareSystemError)
{
- EXPECT_EQ(-EBUSY, performCallback("system_error", []() {
- throw std::system_error(EBUSY, std::generic_category());
- }));
+ EXPECT_EQ(0, performCallback("system_error", []() {
+ throw std::system_error(EBUSY, std::generic_category());
+ }));
}
TEST(UtilsTest, SetPrepareException)
{
- EXPECT_EQ(-ENOSYS, performCallback("runtime_error", []() {
- throw std::runtime_error("Exception");
- }));
+ EXPECT_EQ(0, performCallback("runtime_error", []() {
+ throw std::runtime_error("Exception");
+ }));
}
TEST(UtilsTest, SetPrepareUnknownException)
{
- EXPECT_EQ(-ENOSYS,
+ EXPECT_EQ(0,
performCallback("unknown", []() { throw static_cast<int>(1); }));
}