diff --git a/libs/pbd/enumwriter.cc b/libs/pbd/enumwriter.cc index 3ce296c664..6d911b2dea 100644 --- a/libs/pbd/enumwriter.cc +++ b/libs/pbd/enumwriter.cc @@ -127,7 +127,7 @@ EnumWriter::write (string type, int value) if (x == registry.end()) { error << string_compose (_("EnumWriter: unknown enumeration type \"%1\""), type) << endmsg; - throw unknown_enumeration(); + throw unknown_enumeration (type); } if (x->second.bitwise) { @@ -144,7 +144,7 @@ EnumWriter::read (string type, string value) if (x == registry.end()) { error << string_compose (_("EnumWriter: unknown enumeration type \"%1\""), type) << endmsg; - throw unknown_enumeration(); + throw unknown_enumeration (type); } if (x->second.bitwise) { @@ -267,7 +267,7 @@ EnumWriter::read_bits (EnumRegistration& er, string str) } while (true); if (!found) { - throw unknown_enumeration(); + throw unknown_enumeration (str); } return result; @@ -316,7 +316,7 @@ EnumWriter::read_distinct (EnumRegistration& er, string str) } } - throw unknown_enumeration(); + throw unknown_enumeration(str); } void diff --git a/libs/pbd/pbd/enumwriter.h b/libs/pbd/pbd/enumwriter.h index 600f59bf29..95f1ea9e9f 100644 --- a/libs/pbd/pbd/enumwriter.h +++ b/libs/pbd/pbd/enumwriter.h @@ -25,13 +25,26 @@ #include #include #include - +#include namespace PBD { class unknown_enumeration : public std::exception { public: - virtual const char *what() const throw() { return "unknown enumerator in PBD::EnumWriter"; } + unknown_enumeration (std::string const & e) throw() { + std::stringstream s; + s << "unknown enumerator " << e << " in PBD::EnumWriter"; + _message = s.str (); + } + + ~unknown_enumeration () throw() {} + + virtual const char *what() const throw() { + return _message.c_str(); + } + +private: + std::string _message; }; class EnumWriter {