[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

@@ -28,6 +28,7 @@
#include <wpi/SpanExtras.h>
#include <wpi/StringExtras.h>
#include <wpi/mpack.h>
#include <wpi/print.h>
#include <wpi/raw_ostream.h>
#include "glass/Context.h"
@@ -875,7 +876,7 @@ void NetworkTablesModel::Update() {
std::string err;
auto desc = m_structDb.Add(typeStr, schema, &err);
if (!desc) {
fmt::print("could not decode struct '{}' schema '{}': {}\n",
wpi::print("could not decode struct '{}' schema '{}': {}\n",
entry->info.name, schema, err);
} else if (desc->IsValid()) {
// loop over all entries with this type and update
@@ -900,7 +901,7 @@ void NetworkTablesModel::Update() {
// protobuf descriptor handling
auto filename = wpi::drop_front(entry->info.name, 15);
if (!m_protoDb.Add(filename, entry->value.GetRaw())) {
fmt::print("could not decode protobuf '{}' filename '{}'\n",
wpi::print("could not decode protobuf '{}' filename '{}'\n",
entry->info.name, filename);
} else {
// loop over all protobuf entries and update (conservatively)
@@ -1026,7 +1027,7 @@ void NetworkTablesModel::Client::UpdatePublishers(
if (auto pubs = nt::meta::DecodeClientPublishers(data)) {
publishers = std::move(*pubs);
} else {
fmt::print(stderr, "Failed to update publishers\n");
wpi::print(stderr, "Failed to update publishers\n");
}
}
@@ -1039,7 +1040,7 @@ void NetworkTablesModel::Client::UpdateSubscribers(
subscribers.emplace_back(std::move(sub));
}
} else {
fmt::print(stderr, "Failed to update subscribers\n");
wpi::print(stderr, "Failed to update subscribers\n");
}
}