X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcollection.h;h=f293428c8cdd0fc046019531335ccf6d28b525fc;hb=a02c84384a101c0dec48b6aa2dee53bac4bbd034;hp=5fcaab34f35345406de07e372a70cb972efc2a67;hpb=0812e7601e9ef6081d01b243ba0365aed652d773;p=libs%2Fdatafile.git diff --git a/source/collection.h b/source/collection.h index 5fcaab3..f293428 100644 --- a/source/collection.h +++ b/source/collection.h @@ -192,7 +192,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 +207,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 +239,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; }