maint(fastfiles): better error handling

This commit is contained in:
Diavolo 2023-02-20 16:30:03 +01:00
parent e60f987fff
commit 568ab4ee92
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5

View File

@ -108,14 +108,24 @@ public:
{
console::info("%d %s\n", i, game::native::g_assetNames[i]);
}
return;
}
else
int type;
try
{
const auto type = std::strtol(params.get(1), nullptr, 0);
type = std::stoi(params.get(1), nullptr, 0);
}
catch (const std::exception& ex)
{
console::error("Invalid pool passed. Got: %s, causing error: %s\n", params.get(1), ex.what());
return;
}
if (type < 0 || type >= game::native::ASSET_TYPE_COUNT)
{
console::error("Invalid pool passed must be between [%d, %d]\n", 0, game::native::ASSET_TYPE_COUNT - 1);
console::error("Invalid pool number passed, must be between [%d, %d]\n", 0, game::native::ASSET_TYPE_COUNT - 1);
return;
}
@ -134,7 +144,6 @@ public:
console::info("%s\n", asset_name);
}, true);
}
});
}