X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcollection.h;h=303697a8c726f7c71e99c3a8d8e6582be998b87b;hb=55592b9eeaff3d41e5f03b9c0c1566ed508f38a5;hp=5fcaab34f35345406de07e372a70cb972efc2a67;hpb=0812e7601e9ef6081d01b243ba0365aed652d773;p=libs%2Fdatafile.git diff --git a/source/collection.h b/source/collection.h index 5fcaab3..303697a 100644 --- a/source/collection.h +++ b/source/collection.h @@ -72,6 +72,7 @@ private: */ struct ItemKeywordBase { + virtual ~ItemKeywordBase() { } virtual void add_to_loader(Loader &) const { }; }; @@ -192,7 +193,7 @@ public: void add(const std::string &name, T *d) { if(items.count(name)) - throw KeyError("Duplicate key '"+name+"' in collection"); + throw KeyError("Duplicate key in collection", name); items[name]=new Item::Type>(d); } @@ -207,11 +208,11 @@ public: ItemMap::const_iterator i=items.find(name); if(i==items.end()) - throw KeyError("Item '"+name+"' not found in collection"); + throw KeyError("Item not found in collection", name); const Item *item=dynamic_cast *>(i->second); if(!item) - throw TypeError("Item '"+name+"' is not of correct type"); + throw TypeError("Type mismatch on item '"+name+"'"); return item->data; } @@ -239,12 +240,12 @@ public: return d; } } - throw KeyError("Item '"+name+"' not found in collection"); + throw KeyError("Item not found in collection", name); } const Item *item=dynamic_cast *>(i->second); if(!item) - throw TypeError("Item '"+name+"' is not of correct type"); + throw TypeError("Type mismatch on item '"+name+"'"); return item->data; }