1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 14:59:54 +00:00

Add more details to exceptions

This commit is contained in:
elsid 2023-05-25 20:44:10 +02:00
parent d852ac20f5
commit dc8dfe81ce
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
6 changed files with 15 additions and 6 deletions

View file

@ -296,9 +296,8 @@ namespace CSMWorld
const int index = getIndex(id);
Record<ESXRecordT>& record = *mRecords.at(index);
if (record.isDeleted())
{
throw std::runtime_error("attempt to touch deleted record");
}
throw std::runtime_error("attempt to touch deleted record from collection of "
+ std::string(ESXRecordT::getRecordType()) + ": " + id.toDebugString());
if (!record.isModified())
{
@ -394,7 +393,8 @@ namespace CSMWorld
int index = searchId(id);
if (index == -1)
throw std::runtime_error("invalid ID: " + id.getRefIdString());
throw std::runtime_error("ID is not found in collection of " + std::string(ESXRecordT::getRecordType())
+ " records: " + id.getRefIdString());
return index;
}
@ -427,7 +427,8 @@ namespace CSMWorld
NestableColumn* Collection<ESXRecordT>::getNestableColumn(int column) const
{
if (column < 0 || column >= static_cast<int>(mColumns.size()))
throw std::runtime_error("column index out of range");
throw std::runtime_error(
"column index out of range [0, " + std::to_string(mColumns.size()) + "): " + std::to_string(column));
return mColumns.at(column);
}

View file

@ -16,6 +16,8 @@ namespace CSMWorld
{
struct MetaData
{
static constexpr std::string_view getRecordType() { return "MetaData"; }
ESM::RefId mId;
ESM::FormatVersion mFormatVersion;

View file

@ -658,7 +658,7 @@ int CSMWorld::RefIdCollection::getIndex(const ESM::RefId& id) const
int index = searchId(id);
if (index == -1)
throw std::runtime_error("invalid ID: " + id.toDebugString());
throw std::runtime_error("ID is not found in RefId collection: " + id.toDebugString());
return index;
}

View file

@ -27,6 +27,8 @@ namespace ESM
class CellRef
{
public:
static constexpr std::string_view getRecordType() { return "CellRef"; }
// Reference number
// Note: Currently unused for items in containers
RefNum mRefNum;

View file

@ -15,6 +15,8 @@ namespace ESM
{
constexpr static RecNameInts sRecordId = REC_DBGP;
static constexpr std::string_view getRecordType() { return "DebugProfile"; }
enum Flags
{
Flag_Default = 1, // add to newly opened scene subviews

View file

@ -15,6 +15,8 @@ namespace ESM
{
constexpr static RecNameInts sRecordId = REC_FILT;
static constexpr std::string_view getRecordType() { return "Filter"; }
unsigned int mRecordFlags;
RefId mId;