Improve error message for not found records

pull/617/head
scrawl 10 years ago
parent de98d991b4
commit 28caeadef4

@ -188,7 +188,7 @@ namespace MWWorld
const T *ptr = search(id); const T *ptr = search(id);
if (ptr == 0) { if (ptr == 0) {
std::ostringstream msg; std::ostringstream msg;
msg << "Object '" << id << "' not found (const)"; msg << T::getRecordType() << " '" << id << "' not found";
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
} }
return ptr; return ptr;
@ -202,7 +202,7 @@ namespace MWWorld
if(ptr == 0) if(ptr == 0)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "Object starting with '"<<id<<"' not found (const)"; msg << T::getRecordType() << " starting with '"<<id<<"' not found";
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
} }
return ptr; return ptr;
@ -989,7 +989,7 @@ namespace MWWorld
const T *ptr = search(index); const T *ptr = search(index);
if (ptr == 0) { if (ptr == 0) {
std::ostringstream msg; std::ostringstream msg;
msg << "Object with index " << index << " not found"; msg << T::getRecordType() << " with index " << index << " not found";
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
} }
return ptr; return ptr;

@ -12,6 +12,8 @@ class ESMWriter;
struct Activator struct Activator
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Activator"; }
std::string mId, mName, mScript, mModel; std::string mId, mName, mScript, mModel;

@ -19,6 +19,9 @@ struct Potion
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Potion"; }
struct ALDTstruct struct ALDTstruct
{ {
float mWeight; float mWeight;

@ -16,6 +16,8 @@ class ESMWriter;
struct Apparatus struct Apparatus
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Apparatus"; }
enum AppaType enum AppaType
{ {

@ -66,6 +66,8 @@ struct PartReferenceList
struct Armor struct Armor
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Armor"; }
enum Type enum Type
{ {

@ -12,6 +12,8 @@ class ESMWriter;
struct BodyPart struct BodyPart
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "BodyPart"; }
enum MeshPart enum MeshPart
{ {

@ -15,6 +15,8 @@ class ESMWriter;
struct Book struct Book
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Book"; }
struct BKDTstruct struct BKDTstruct
{ {

@ -14,6 +14,8 @@ class ESMWriter;
struct BirthSign struct BirthSign
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "BirthSign"; }
std::string mId, mName, mDescription, mTexture; std::string mId, mName, mDescription, mTexture;

@ -56,6 +56,8 @@ typedef std::list<CellRef> CellRefTracker;
struct Cell struct Cell
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Cell"; }
enum Flags enum Flags
{ {

@ -18,6 +18,8 @@ class ESMWriter;
struct Class struct Class
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Class"; }
enum AutoCalc enum AutoCalc
{ {

@ -18,6 +18,8 @@ class ESMWriter;
struct Clothing struct Clothing
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Clothing"; }
enum Type enum Type
{ {

@ -36,6 +36,8 @@ struct InventoryList
struct Container struct Container
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Container"; }
enum Flags enum Flags
{ {

@ -22,6 +22,8 @@ class ESMWriter;
struct Creature struct Creature
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Creature"; }
// Default is 0x48? // Default is 0x48?
enum Flags enum Flags

@ -21,6 +21,8 @@ class ESMWriter;
struct Dialogue struct Dialogue
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Dialogue"; }
enum Type enum Type
{ {

@ -12,6 +12,8 @@ class ESMWriter;
struct Door struct Door
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Door"; }
std::string mId, mName, mModel, mScript, mOpenSound, mCloseSound; std::string mId, mName, mModel, mScript, mOpenSound, mCloseSound;

@ -18,6 +18,8 @@ class ESMWriter;
struct Enchantment struct Enchantment
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Enchantment"; }
enum Type enum Type
{ {

@ -30,6 +30,8 @@ struct RankData
struct Faction struct Faction
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Faction"; }
std::string mId, mName; std::string mId, mName;

@ -18,6 +18,8 @@ class ESMWriter;
struct Global struct Global
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Global"; }
std::string mId; std::string mId;
Variant mValue; Variant mValue;

@ -19,6 +19,8 @@ class ESMWriter;
struct GameSetting struct GameSetting
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "GameSetting"; }
std::string mId; std::string mId;

@ -21,6 +21,8 @@ class ESMWriter;
struct DialInfo struct DialInfo
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "DialInfo"; }
enum Gender enum Gender
{ {

@ -16,6 +16,8 @@ class ESMWriter;
struct Ingredient struct Ingredient
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Ingredient"; }
struct IRDTstruct struct IRDTstruct
{ {

@ -18,6 +18,8 @@ class ESMWriter;
struct Land struct Land
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Land"; }
Land(); Land();
~Land(); ~Land();

@ -46,6 +46,8 @@ struct LevelledListBase
struct CreatureLevList: LevelledListBase struct CreatureLevList: LevelledListBase
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "CreatureLevList"; }
enum Flags enum Flags
{ {
@ -64,6 +66,8 @@ struct CreatureLevList: LevelledListBase
struct ItemLevList: LevelledListBase struct ItemLevList: LevelledListBase
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "ItemLevList"; }
enum Flags enum Flags
{ {

@ -17,6 +17,8 @@ class ESMWriter;
struct Light struct Light
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Light"; }
enum Flags enum Flags
{ {

@ -12,6 +12,8 @@ class ESMWriter;
struct Lockpick struct Lockpick
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Lockpick"; }
struct Data struct Data
{ {

@ -28,6 +28,8 @@ class ESMWriter;
struct LandTexture struct LandTexture
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "LandTexture"; }
std::string mId, mTexture; std::string mId, mTexture;
int mIndex; int mIndex;

@ -13,6 +13,8 @@ class ESMWriter;
struct MagicEffect struct MagicEffect
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "MagicEffect"; }
std::string mId; std::string mId;

@ -17,6 +17,8 @@ class ESMWriter;
struct Miscellaneous struct Miscellaneous
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Miscellaneous"; }
struct MCDTstruct struct MCDTstruct
{ {

@ -23,6 +23,8 @@ class ESMWriter;
struct NPC struct NPC
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "NPC"; }
// Services // Services
enum Services enum Services

@ -16,6 +16,8 @@ class ESMWriter;
struct Pathgrid struct Pathgrid
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Pathgrid"; }
struct DATAstruct struct DATAstruct
{ {

@ -12,6 +12,8 @@ class ESMWriter;
struct Probe struct Probe
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Probe"; }
struct Data struct Data
{ {

@ -18,6 +18,8 @@ class ESMWriter;
struct Race struct Race
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Race"; }
struct SkillBonus struct SkillBonus
{ {

@ -19,6 +19,8 @@ class ESMWriter;
struct Region struct Region
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Region"; }
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)

@ -12,6 +12,8 @@ class ESMWriter;
struct Repair struct Repair
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Repair"; }
struct Data struct Data
{ {

@ -20,6 +20,8 @@ class Script
{ {
public: public:
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Script"; }
struct SCHDstruct struct SCHDstruct
{ {

@ -20,6 +20,8 @@ class ESMWriter;
struct Skill struct Skill
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Skill"; }
std::string mId; std::string mId;

@ -16,6 +16,8 @@ class ESMWriter;
struct SoundGenerator struct SoundGenerator
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "SoundGenerator"; }
enum Type enum Type
{ {

@ -17,6 +17,8 @@ struct SOUNstruct
struct Sound struct Sound
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Sound"; }
SOUNstruct mData; SOUNstruct mData;
std::string mId, mSound; std::string mId, mSound;

@ -14,6 +14,8 @@ class ESMWriter;
struct Spell struct Spell
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Spell"; }
enum SpellType enum SpellType
{ {

@ -20,6 +20,8 @@ class ESMWriter;
struct StartScript struct StartScript
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "StartScript"; }
std::string mData; std::string mData;
std::string mId; std::string mId;

@ -23,6 +23,8 @@ class ESMWriter;
struct Static struct Static
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Static"; }
std::string mId, mModel; std::string mId, mModel;

@ -16,6 +16,8 @@ class ESMWriter;
struct Weapon struct Weapon
{ {
static unsigned int sRecordId; static unsigned int sRecordId;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string getRecordType() { return "Weapon"; }
enum Type enum Type
{ {

Loading…
Cancel
Save