Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions loader/src/utils/general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ float geode::utils::getDisplayFactor() {
template <typename T>
static Result<T> 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 <typename T>
Expand Down
Loading