diff --git a/src/base/error.h b/src/base/error.h index d9fba79..9fdc187 100644 --- a/src/base/error.h +++ b/src/base/error.h @@ -35,7 +35,7 @@ class CommandExecutionException : public BaseException { class ParserException : public BaseException { public: explicit ParserException(std::string_view raw_str, std::string_view message) - : BaseException(fmt::format("[exception.parser] (str: {}) {}")) {} + : BaseException(fmt::format("[exception.parser] (str: {}) {}", raw_str, message)) {} }; class NeedUpdateException : public BaseException { diff --git a/src/base/version.cpp b/src/base/version.cpp index a7fa890..c173ae6 100644 --- a/src/base/version.cpp +++ b/src/base/version.cpp @@ -6,17 +6,24 @@ namespace allay_launcher { std::optional Version::parse(std::string_view str) { auto tokens = util::string::split(str, "."); - if (tokens.size() < 3) { + if (tokens.size() > 3) { return {}; } - auto major = util::string::to_int32(tokens.at(0)); - auto minor = util::string::to_int32(tokens.at(1)); - auto revision = util::string::to_int32(tokens.at(2)); + // major(require),minor,revision + std::vector> version = {0, 0, 0}; - if (!major || !minor || !revision) return {}; + auto vId = 0; + for (const auto& item : tokens) { + version[vId] = util::string::to_int32(tokens[vId]); + vId++; + } - return Version{*major, *minor, *revision}; + if (!version[0]) return {}; + auto ret = Version{*version[0], 0, 0}; + if (version[1]) ret.m_minor = *version[1]; + if (version[2]) ret.m_revision = *version[2]; + return ret; } } // namespace allay_launcher \ No newline at end of file