[wpilibc] Errors: Use fmtlib

This commit is contained in:
Peter Johnson
2021-05-23 19:33:33 -07:00
parent 87603e400d
commit 831c10bdfc
55 changed files with 551 additions and 533 deletions

View File

@@ -30,16 +30,16 @@ uint32_t Resource::Allocate(const std::string& resourceDesc) {
return i;
}
}
throw FRC_MakeError(err::NoAvailableResources, resourceDesc);
throw FRC_MakeError(err::NoAvailableResources, "{}", resourceDesc);
}
uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
std::scoped_lock lock(m_allocateMutex);
if (index >= m_isAllocated.size()) {
throw FRC_MakeError(err::ChannelIndexOutOfRange, resourceDesc);
throw FRC_MakeError(err::ChannelIndexOutOfRange, "{}", resourceDesc);
}
if (m_isAllocated[index]) {
throw FRC_MakeError(err::ResourceAlreadyAllocated, resourceDesc);
throw FRC_MakeError(err::ResourceAlreadyAllocated, "{}", resourceDesc);
}
m_isAllocated[index] = true;
return index;
@@ -51,10 +51,10 @@ void Resource::Free(uint32_t index) {
return;
}
if (index >= m_isAllocated.size()) {
throw FRC_MakeError(err::NotAllocated, "index " + wpi::Twine{index});
throw FRC_MakeError(err::NotAllocated, "index {}", index);
}
if (!m_isAllocated[index]) {
throw FRC_MakeError(err::NotAllocated, "index " + wpi::Twine{index});
throw FRC_MakeError(err::NotAllocated, "index {}", index);
}
m_isAllocated[index] = false;
}