diff options
| author | William A. Kennington III <wak@google.com> | 2018-07-17 16:54:36 -0700 |
|---|---|---|
| committer | William A. Kennington III <wak@google.com> | 2018-07-17 16:54:55 -0700 |
| commit | 4e9e604f02da41da974607be1ee00b0252776c82 (patch) | |
| tree | e59c0e9b747c089ceebcde09ace6397b25c9a0ab /src | |
| parent | feef68f751e09d8d5a4f2bf2f2f4cab27de1b73e (diff) | |
| download | sdeventplus-4e9e604f02da41da974607be1ee00b0252776c82.tar.gz sdeventplus-4e9e604f02da41da974607be1ee00b0252776c82.zip | |
internal/utils: Errors now have names
Diffstat (limited to 'src')
| -rw-r--r-- | src/sdeventplus/internal/utils.hpp | 8 | ||||
| -rw-r--r-- | src/sdeventplus/source/base.cpp | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/sdeventplus/internal/utils.hpp b/src/sdeventplus/internal/utils.hpp index c0b0e68..17e8cee 100644 --- a/src/sdeventplus/internal/utils.hpp +++ b/src/sdeventplus/internal/utils.hpp @@ -19,7 +19,7 @@ namespace internal // Helpers for sd_event callbacks to handle exceptions gracefully template <typename Func, typename... Args> -static int performCallback(Func func, Args... args) +static int performCallback(const char* name, Func func, Args... args) { try { @@ -28,17 +28,17 @@ static int performCallback(Func func, Args... args) } catch (const std::system_error& e) { - fprintf(stderr, "sdeventplus: callback: %s\n", e.what()); + fprintf(stderr, "sdeventplus: %s: %s\n", name, e.what()); return -e.code().value(); } catch (const std::exception& e) { - fprintf(stderr, "sdeventplus: callback: %s\n", e.what()); + fprintf(stderr, "sdeventplus: %s: %s\n", name, e.what()); return -ENOSYS; } catch (...) { - fprintf(stderr, "sdeventplus: callback: Unknown error\n"); + fprintf(stderr, "sdeventplus: %s: Unknown error\n", name); return -ENOSYS; } } diff --git a/src/sdeventplus/source/base.cpp b/src/sdeventplus/source/base.cpp index 5f202db..32e6edf 100644 --- a/src/sdeventplus/source/base.cpp +++ b/src/sdeventplus/source/base.cpp @@ -61,7 +61,8 @@ static int prepare_callback(sd_event_source*, void* userdata) return -EINVAL; } Base* base = reinterpret_cast<Base*>(userdata); - return internal::performCallback(base->get_prepare(), std::ref(*base)); + return internal::performCallback("prepare_callback", base->get_prepare(), + std::ref(*base)); } void Base::set_prepare(Callback&& callback) |

