From 45b0307d42b22e04cee63467a8fdb898a2d8d552 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 5 Sep 2025 13:02:27 +0200 Subject: refactor zen command return value handling (#487) - Improvement: Use consistent language for command line argument parsing errors - Improvement: Changed zen command parsing errors to output help first and error last to make it easier to spot the error - Improvement: Refactor zen command return codes to conform to valid Linux range (0-255) kSuccess = 0, kOtherError = 1, kBadInput = 2, kOutOfMemory = 16, kOutOfDisk = 17, kAssertError = 70, kHttpOtherClientError = 80, kHttpCantConnectError = 81, kHttpNotFound = 66, // NotFound(404) kHttpUnauthorized = 77, // Unauthorized(401), kHttpSLLError = 82, kHttpForbidden = 83, // Forbidden(403) kHttpTimeout = 84, // RequestTimeout(408) kHttpConflict = 85, // Conflict(409) kHttpNoHost = 86, kHttpOtherServerError = 90, kHttpInternalServerError = 91, // InternalServerError(500) kHttpServiceUnavailable = 69, // ServiceUnavailable(503) kHttpBadGateway = 92, // BadGateway(502) kHttpGatewayTimeout = 93, // GatewayTimeout(504) --- src/zencore/include/zencore/except.h | 4 +++- src/zencore/include/zencore/uid.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/zencore/include') diff --git a/src/zencore/include/zencore/except.h b/src/zencore/include/zencore/except.h index 6810e6ea9..c933adfd8 100644 --- a/src/zencore/include/zencore/except.h +++ b/src/zencore/include/zencore/except.h @@ -63,7 +63,9 @@ MakeErrorCodeFromLastError() noexcept class OptionParseException : public std::runtime_error { public: - inline explicit OptionParseException(const std::string& Message) : std::runtime_error(Message) {} + // inline explicit OptionParseException(const std::string& Message) : std::runtime_error(Message) {} + inline OptionParseException(const std::string& Message, const std::string& Help) : std::runtime_error(Message), m_Help(Help) {} + const std::string m_Help; }; bool IsOOM(const std::system_error& SystemError); diff --git a/src/zencore/include/zencore/uid.h b/src/zencore/include/zencore/uid.h index 64d3b6b9b..0c1079444 100644 --- a/src/zencore/include/zencore/uid.h +++ b/src/zencore/include/zencore/uid.h @@ -55,8 +55,8 @@ class StringBuilderBase; struct Oid { - static const int StringLength = 24; - typedef char String_t[StringLength + 1]; + static constexpr int StringLength = 24; + typedef char String_t[StringLength + 1]; static void Initialize(); [[nodiscard]] static Oid NewOid(); -- cgit v1.2.3