Skip to content

Commit

Permalink
refactor: handle exceptions correctly also in match callback handlers (
Browse files Browse the repository at this point in the history
…#386)

This is a follow-up to #375. It covers match callback handlers that were missed in #375.
  • Loading branch information
sangelovic authored Dec 5, 2023
1 parent 47a84ab commit 721f583
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,20 +587,20 @@ std::vector</*const */char*> Connection::to_strv(const std::vector<std::string>&
return strv;
}

int Connection::sdbus_match_callback(sd_bus_message *sdbusMessage, void *userData, sd_bus_error */*retError*/)
int Connection::sdbus_match_callback(sd_bus_message *sdbusMessage, void *userData, sd_bus_error *retError)
{
auto* matchInfo = static_cast<MatchInfo*>(userData);
auto message = Message::Factory::create<PlainMessage>(sdbusMessage, &matchInfo->connection.getSdBusInterface());
matchInfo->callback(message);
return 0;
auto ok = invokeHandlerAndCatchErrors([&](){ matchInfo->callback(message); }, retError);
return ok ? 0 : -1;
}

int Connection::sdbus_match_install_callback(sd_bus_message *sdbusMessage, void *userData, sd_bus_error */*retError*/)
int Connection::sdbus_match_install_callback(sd_bus_message *sdbusMessage, void *userData, sd_bus_error *retError)
{
auto* matchInfo = static_cast<MatchInfo*>(userData);
auto message = Message::Factory::create<PlainMessage>(sdbusMessage, &matchInfo->connection.getSdBusInterface());
matchInfo->installCallback(message);
return 0;
auto ok = invokeHandlerAndCatchErrors([&](){ matchInfo->installCallback(message); }, retError);
return ok ? 0 : -1;
}

Connection::EventFd::EventFd()
Expand Down

0 comments on commit 721f583

Please sign in to comment.