From f4bee142c177787b9095f01ce67b3492285c9ed8 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Wed, 24 Jan 2024 14:01:09 -0500 Subject: [PATCH] Add a couple of throws for bad states --- folly/experimental/io/EpollBackend.cpp | 4 +++- folly/experimental/settings/Types.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/folly/experimental/io/EpollBackend.cpp b/folly/experimental/io/EpollBackend.cpp index b05353e3c1c..a86fbc11bb9 100644 --- a/folly/experimental/io/EpollBackend.cpp +++ b/folly/experimental/io/EpollBackend.cpp @@ -94,7 +94,9 @@ void SignalRegistry::notify(int sig) { int fd = notifyFd_.load(); if (fd >= 0) { uint8_t sigNum = static_cast(sig); - ::write(fd, &sigNum, 1); + if (::write(fd, &sigNum, 1) != 1) { + throw std::runtime_error("Failed to write all the byes."); + } } } diff --git a/folly/experimental/settings/Types.cpp b/folly/experimental/settings/Types.cpp index 276d99b8668..924de464720 100644 --- a/folly/experimental/settings/Types.cpp +++ b/folly/experimental/settings/Types.cpp @@ -16,6 +16,8 @@ #include +#include + namespace folly { namespace settings { @@ -27,6 +29,8 @@ std::string_view toString(SetErrorCode code) { return "rejected"; case SetErrorCode::FrozenImmutable: return "frozen immutable"; + default: + throw std::invalid_argument("Code '" + std::to_string(static_cast(code)) + "' had no string representation!"); } }