[wpiutil] Upgrade to fmt 10.2.1, add wpi::print (#6161)

We now use a wrapper (wpi::print) to catch exceptions since we can't patch
std::print() to not throw when we ultimately migrate to it.

fmtlib and std format/print throw the same exceptions and always have. We previously patched fmt::print() to not throw a write failure exception, but we can't do that for std::print(); wpi::print() is the migration plan.
This commit is contained in:
Tyler Veness
2024-05-12 06:25:42 -07:00
committed by GitHub
parent 6c9dcc157e
commit d88c71ffdc
99 changed files with 1374 additions and 1130 deletions

View File

@@ -6,10 +6,10 @@
#include <cstdio>
#include <fmt/format.h>
#include <wpi/Endian.h>
#include <wpi/MathExtras.h>
#include <wpi/SmallString.h>
#include <wpi/print.h>
#include <wpinet/raw_uv_ostream.h>
#include <wpinet/uv/util.h>
@@ -24,7 +24,7 @@ HALSimXRP::HALSimXRP(wpi::uv::Loop& loop,
m_providers(providers),
m_simDevicesProvider(simDevicesProvider) {
m_loop.error.connect([](uv::Error err) {
fmt::print(stderr, "HALSim XRP Client libuv Error: {}\n", err.str());
wpi::print(stderr, "HALSim XRP Client libuv Error: {}\n", err.str());
});
m_udp_client = uv::Udp::Create(m_loop);
@@ -51,7 +51,7 @@ bool HALSimXRP::Initialize() {
try {
m_port = std::stoi(port);
} catch (const std::invalid_argument& err) {
fmt::print(stderr, "Error decoding HALSIMXRP_PORT ({})\n", err.what());
wpi::print(stderr, "Error decoding HALSIMXRP_PORT ({})\n", err.what());
return false;
}
} else {
@@ -79,7 +79,7 @@ void HALSimXRP::Start() {
ParsePacket({reinterpret_cast<uint8_t*>(data.base), len});
});
m_udp_client->closed.connect([]() { fmt::print("Socket Closed\n"); });
m_udp_client->closed.connect([]() { wpi::print("Socket Closed\n"); });
// Fake the OnNetworkConnected call
auto hws = shared_from_this();
@@ -120,7 +120,7 @@ void HALSimXRP::OnNetValueChanged(const wpi::json& msg) {
provider->OnNetValueChanged(msg.at("data"));
}
} catch (wpi::json::exception& e) {
fmt::print(stderr, "Error with incoming message: {}\n", e.what());
wpi::print(stderr, "Error with incoming message: {}\n", e.what());
}
}