fix: three errors that ended with the wrong exit code
Found compiling the environment-variable table for AGENTS.md: - A REVIEW_GATES_MEM_RESERVE_MB that is no number threw std::invalid_argument, which nothing caught: the process aborted where it should end with a ValueError, exit 1. nan and inf were an unchecked cast. They raise ValueError / OverflowError now; a value past int64 saturates. - An env file that is not UTF-8: `run` ended with exit 1 where its preflight should stop it (exit 3), and `seats` parsed the raw bytes. Both read it as strict UTF-8 text now. - A broker address with a port past 65535 was cut to 16 bits; it is an OverflowError now, uncaught (exit 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b092d98697
commit
53b7d6de31
9 changed files with 58 additions and 14 deletions
|
|
@ -20,8 +20,15 @@ namespace Crafter::Review::Memory {
|
|||
|
||||
std::int64_t Reserve(const std::optional<std::string>& configured, const fs::path& path) {
|
||||
if (configured && !configured->empty()) {
|
||||
// A number, truncated toward zero; ValueError or OverflowError for
|
||||
// what is none. A reserve past int64 saturates: it holds every MB
|
||||
// either way.
|
||||
const std::optional<double> value = Dyn::ParseFloat(*configured);
|
||||
if (!value) throw std::invalid_argument(Dyn::FloatError(*configured));
|
||||
if (!value) throw Dyn::Error("ValueError", Dyn::FloatError(*configured));
|
||||
if (std::isnan(*value)) throw Dyn::Error("ValueError", "cannot convert float NaN to integer");
|
||||
if (std::isinf(*value)) throw Dyn::Error("OverflowError", "cannot convert float infinity to integer");
|
||||
if (*value >= 0x1p63) return std::numeric_limits<std::int64_t>::max();
|
||||
if (*value < -0x1p63) return std::numeric_limits<std::int64_t>::min();
|
||||
return static_cast<std::int64_t>(*value);
|
||||
}
|
||||
const std::map<std::string, std::int64_t> info = Platform::MemInfo(path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue