From 364977ef4081a273f1a4832cd571864cf0922131 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 22 Nov 2023 19:11:40 +0200 Subject: [PATCH] More meaningful exception messages --- lib/IHandlerBase.h | 2 +- lib/mapObjects/CGTownInstance.cpp | 2 +- lib/mapObjects/MiscObjects.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/IHandlerBase.h b/lib/IHandlerBase.h index 615e23f54..8bf602887 100644 --- a/lib/IHandlerBase.h +++ b/lib/IHandlerBase.h @@ -116,7 +116,7 @@ public: if(index < 0 || index >= objects.size()) { logMod->error("%s id %d is invalid", getTypeNames()[0], index); - throw std::runtime_error("internal error"); + throw std::runtime_error("Attempt to access invalid index " + std::to_string(index) + " of type " + getTypeNames().front()); } return objects[index]; diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index f7b5081f5..9813c4a58 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -1079,7 +1079,7 @@ void CGTownInstance::addHeroToStructureVisitors(const CGHeroInstance *h, si64 st { //should never ever happen logGlobal->error("Cannot add hero %s to visitors of structure # %d", h->getNameTranslated(), structureInstanceID); - throw std::runtime_error("internal error"); + throw std::runtime_error("unexpected hero in CGTownInstance::addHeroToStructureVisitors"); } } diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index c3369810b..fa89b76d7 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -1239,7 +1239,7 @@ void CGObelisk::setPropertyDer(ObjProperty what, ObjPropertyID identifier) if(progress > obeliskCount) { logGlobal->error("Visited %d of %d", static_cast(progress), obeliskCount); - throw std::runtime_error("internal error"); + throw std::runtime_error("Player visited more obelisks than present on map!"); } break;