diff --git a/MMDevice/ImageMetadata.h b/MMDevice/ImageMetadata.h index 212d7b084..7790b010b 100644 --- a/MMDevice/ImageMetadata.h +++ b/MMDevice/ImageMetadata.h @@ -55,6 +55,9 @@ class MetadataError return message_; } + /// Implements std::exception interface. + virtual const char* what() const throw() { return message_.c_str(); } + private: std::string message_; }; @@ -64,6 +67,8 @@ class MetadataKeyError : public MetadataError public: MetadataKeyError() : MetadataError("Undefined metadata key") {} + MetadataKeyError(const char* key) : + MetadataError(("Undefined metadata key: " + std::string(key)).c_str()) {} ~MetadataKeyError() {} }; @@ -487,7 +492,7 @@ class Metadata if (it != tags_.end()) return it->second; else - throw MetadataKeyError(); + throw MetadataKeyError(key); } std::map tags_;