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
|
|
@ -1120,14 +1120,17 @@ namespace Crafter::Review::PgWire {
|
|||
const std::size_t colon = where.rfind(':');
|
||||
const std::string host(colon == std::string_view::npos ? std::string_view() : where.substr(0, colon));
|
||||
const std::string portText(colon == std::string_view::npos ? where : where.substr(colon + 1));
|
||||
const std::optional<std::int64_t> port = Dyn::ParseInt(portText);
|
||||
if (!port) {
|
||||
out(std::format("{} - the driver's SQL broker does not answer ({})", NoDatabase, Dyn::IntError(portText)));
|
||||
return ExitNoDb;
|
||||
}
|
||||
// socket.create_connection raised OverflowError for it, which
|
||||
// call_broker did not catch: the helper ended in a traceback.
|
||||
if (*port < 0 || *port > 65535) throw Dyn::Error("OverflowError", "getsockaddrarg: port must be 0-65535.");
|
||||
std::unique_ptr<ClientTCP> socket;
|
||||
try {
|
||||
const std::optional<std::int64_t> port = Dyn::ParseInt(portText);
|
||||
if (!port) throw std::invalid_argument(Dyn::IntError(portText));
|
||||
socket = std::make_unique<ClientTCP>(host, static_cast<std::uint16_t>(*port), std::chrono::seconds(5));
|
||||
} catch (const std::invalid_argument& error) {
|
||||
out(std::format("{} - the driver's SQL broker does not answer ({})", NoDatabase, error.what()));
|
||||
return ExitNoDb;
|
||||
} catch (const std::exception& error) {
|
||||
out(std::format("{} - the driver's SQL broker does not answer ({})", NoDatabase, ConnectErrorText(error)));
|
||||
return ExitNoDb;
|
||||
|
|
|
|||
Loading…
Reference in a new issue