mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Throw "resource not found" instead of crashing on invalid query
This commit is contained in:
parent
c78382c515
commit
2d8692c142
@ -339,20 +339,25 @@ void CModHandler::loadModFilesystems()
|
||||
|
||||
TModID CModHandler::findResourceOrigin(const ResourcePath & name) const
|
||||
{
|
||||
for(const auto & modID : boost::adaptors::reverse(activeMods))
|
||||
try
|
||||
{
|
||||
if(CResourceHandler::get(modID)->existsResource(name))
|
||||
return modID;
|
||||
for(const auto & modID : boost::adaptors::reverse(activeMods))
|
||||
{
|
||||
if(CResourceHandler::get(modID)->existsResource(name))
|
||||
return modID;
|
||||
}
|
||||
|
||||
if(CResourceHandler::get("core")->existsResource(name))
|
||||
return "core";
|
||||
|
||||
if(CResourceHandler::get("mapEditor")->existsResource(name))
|
||||
return "core"; // Workaround for loading maps via map editor
|
||||
}
|
||||
|
||||
if(CResourceHandler::get("core")->existsResource(name))
|
||||
return "core";
|
||||
|
||||
if(CResourceHandler::get("mapEditor")->existsResource(name))
|
||||
return "core"; // Workaround for loading maps via map editor
|
||||
|
||||
assert(0);
|
||||
return "";
|
||||
catch( const std::out_of_range & e)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
throw std::runtime_error("Resource with name " + name.getName() + " and type " + EResTypeHelper::getEResTypeAsString(name.getType()) + " wasn't found.");
|
||||
}
|
||||
|
||||
std::string CModHandler::getModLanguage(const TModID& modId) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user