diff --git a/loader/src/utils/general.cpp b/loader/src/utils/general.cpp index 3b265cae1..9d1ccd0aa 100644 --- a/loader/src/utils/general.cpp +++ b/loader/src/utils/general.cpp @@ -13,11 +13,14 @@ float geode::utils::getDisplayFactor() { template static Result toParseResult(T* value, fast_float::from_chars_result res, std::string_view str) { auto [ptr, ec] = res; - if (ec == std::errc()) return Ok(*value); - else if (ptr != str.data() + str.size()) return Err("String contains trailing extra data"); - else if (ec == std::errc::invalid_argument) return Err("String is not a number"); - else if (ec == std::errc::result_out_of_range) return Err("Number is out of range for target type"); - else return Err("Unknown error"); + + if (ec == std::errc::invalid_argument) return Err("String is not a number"); + if (ec == std::errc::result_out_of_range) return Err("Number is out of range for target type"); + if (ec != std::errc()) return Err(std::make_error_code(ec).message()); + + if (ptr != str.data() + str.size()) return Err("String contains trailing data"); + + return Ok(*value); } template