fix: toml without exceptions usage

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-07-01 13:38:32 -07:00
parent e2a65a7077
commit 2a5d291bd9
No known key found for this signature in database
GPG Key ID: E10E321EB160949B
2 changed files with 8 additions and 6 deletions

View File

@ -104,14 +104,15 @@ ModDetails ReadMCModTOML(QByteArray contents)
#if TOML_EXCEPTIONS #if TOML_EXCEPTIONS
try { try {
tomlData = toml::parse(contents.toStdString()); tomlData = toml::parse(contents.toStdString());
} catch (const toml::parse_error& err) { } catch ([[maybe_unused]] const toml::parse_error& err) {
return {}; return {};
} }
#else #else
tomlData = toml::parse(contents.toStdString()); toml::parse_result result = toml::parse(contents.toStdString());
if (!tomlData) { if (!result) {
return {}; return {};
} }
tomlData = result.table();
#endif #endif
// array defined by [[mods]] // array defined by [[mods]]

View File

@ -241,12 +241,13 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
return {}; return {};
} }
#else #else
table = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname))); toml::parse_result result = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
if (!table) { if (!result) {
qWarning() << QString("Could not open file %1!").arg(normalized_fname); qWarning() << QString("Could not open file %1!").arg(normalized_fname);
qWarning() << "Reason: " << QString(table.error().what()); qWarning() << "Reason: " << result.error().description();
return {}; return {};
} }
table = result.table();
#endif #endif
// index_file.close(); // index_file.close();