Skip to content

Commit

Permalink
Apparently I was trying to find a parsing bug a year ago.
Browse files Browse the repository at this point in the history
Apologies to anyone that ran into this.
  • Loading branch information
kitlith committed Jun 19, 2024
1 parent bb68931 commit 3397eda
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,16 @@ std::optional<UniverseTranslation> search_universe(simdjson::ondemand::parser &j

for (simdjson::ondemand::object uni: doc["universes"]) {
// TODO: universeID comes after the translation, would it be faster to unconditionally parse the translation?
simdjson::ondemand::value elem = uni["universeID"];
auto res = uni.find_field_unordered("universeID");
if (res.error()) {
static bool missingId = false;
if (!missingId) {
missingId = true;
fmt::print("Warning: 'universes' are present that don't have a universeID, skipping.");
}
continue;
}
simdjson::ondemand::value elem = res.value_unsafe(); // uni["universeID"];

uint64_t parsed_universe;
auto is_integer = elem.is_integer();
Expand All @@ -700,11 +709,20 @@ std::optional<UniverseTranslation> search_universe(simdjson::ondemand::parser &j
}
} catch (simdjson::simdjson_error& e) {
std::string_view raw_token_view;

static bool parse_error = false;
if (parse_error) {
return std::nullopt;
}

if (!doc.raw_json_token().get(raw_token_view)) {
fmt::print("Error while parsing steamvr universes: {}\nraw_token: |{}|\n", e.error(), raw_token_view);
} else {
fmt::print("Error while parsing steamvr universes: {}\n", e.error());
}

parse_error = true;

return std::nullopt;
}

Expand Down

0 comments on commit 3397eda

Please sign in to comment.