mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Added better error reporting for unclear crashes
This commit is contained in:
@@ -182,6 +182,9 @@ void CPlayerInterface::closeAllDialogs()
|
|||||||
if(infoWindow && infoWindow->ID != QueryID::NONE)
|
if(infoWindow && infoWindow->ID != QueryID::NONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (topWindow == nullptr)
|
||||||
|
throw std::runtime_error("Invalid or non-existing top window! Total windows: " + std::to_string(GH.windows().count()));
|
||||||
|
|
||||||
topWindow->close();
|
topWindow->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,6 +343,9 @@ WindowBase::WindowBase(int used_, Point pos_)
|
|||||||
void WindowBase::close()
|
void WindowBase::close()
|
||||||
{
|
{
|
||||||
if(!GH.windows().isTopWindow(this))
|
if(!GH.windows().isTopWindow(this))
|
||||||
throw std::runtime_error("Only top interface can be closed");
|
{
|
||||||
|
auto topWindow = GH.windows().topWindow<IShowActivatable>().get();
|
||||||
|
throw std::runtime_error(std::string("Only top interface can be closed! Top window is ") + typeid(*this).name() + " but attempted to close " + typeid(*topWindow).name());
|
||||||
|
}
|
||||||
GH.windows().popWindows(1);
|
GH.windows().popWindows(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,11 +211,18 @@ void CAnimation::createFlippedGroup(const size_t sourceGroup, const size_t targe
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageLocator CAnimation::getImageLocator(size_t frame, size_t group) const
|
ImageLocator CAnimation::getImageLocator(size_t frame, size_t group) const
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
const ImageLocator & locator = source.at(group).at(frame);
|
const ImageLocator & locator = source.at(group).at(frame);
|
||||||
|
|
||||||
if (!locator.empty())
|
if (!locator.empty())
|
||||||
return locator;
|
return locator;
|
||||||
|
}
|
||||||
|
catch (std::out_of_range &)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Frame " + std::to_string(frame) + " of group " + std::to_string(group) + " is missing from animation " + name.getOriginalName() );
|
||||||
|
}
|
||||||
|
|
||||||
return ImageLocator(name, frame, group);
|
return ImageLocator(name, frame, group);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,9 +394,16 @@ void CGTownInstance::initializeConfigurableBuildings(vstd::RNG & rand)
|
|||||||
{
|
{
|
||||||
for(const auto & kvp : getTown()->buildings)
|
for(const auto & kvp : getTown()->buildings)
|
||||||
{
|
{
|
||||||
if(!kvp.second->rewardableObjectInfo.getParameters().isNull())
|
if(kvp.second->rewardableObjectInfo.getParameters().isNull())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try {
|
||||||
rewardableBuildings[kvp.first] = new TownRewardableBuildingInstance(this, kvp.second->bid, rand);
|
rewardableBuildings[kvp.first] = new TownRewardableBuildingInstance(this, kvp.second->bid, rand);
|
||||||
}
|
}
|
||||||
|
catch (std::runtime_error & e) {
|
||||||
|
throw std::runtime_error("Failed to load rewardable building data for " + kvp.second->getJsonKey() + " Reason: " + e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DamageRange CGTownInstance::getTowerDamageRange() const
|
DamageRange CGTownInstance::getTowerDamageRange() const
|
||||||
|
|||||||
Reference in New Issue
Block a user