Skip to content

Commit

Permalink
fix: don't crash on bad manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMcAvoy committed Jan 16, 2025
1 parent f40962c commit b6ecff3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CarbonLauncher/src/modmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ std::optional<Mod> ModManager::JSONToMod(const nlohmann::json& jMod) {

if (hasManifest) {
spdlog::trace("Mod {} has a manifest.json!", ghUser + "/" + ghRepo);
auto jManifest = nlohmann::json::parse(manifest.text);
//auto jManifest = nlohmann::json::parse(manifest.text);
nlohmann::json jManifest;
try {
jManifest = nlohmann::json::parse(manifest.text);
}
catch (nlohmann::json::parse_error& e) {
spdlog::error("Failed to parse JSON: {}", e.what());
return std::nullopt;
}

mod.name = jManifest["name"];
mod.authors = jManifest["authors"].get<std::vector<std::string>>();
Expand Down

0 comments on commit b6ecff3

Please sign in to comment.