summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-06-18 18:28:19 +0000
committerCarl Hetherington <carl@carlh.net>2012-06-18 18:28:19 +0000
commit24b418598ad2637f1f929380047f85d2cf2b7b33 (patch)
treeb7789c030669391c77daec2537f49034bc9226b1
parent49fec4f43072f2600c921ea714dacc868370aa53 (diff)
Make EnumWriter exceptions a bit more informative.
git-svn-id: svn://localhost/ardour2/branches/3.0@12758 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/pbd/enumwriter.cc8
-rw-r--r--libs/pbd/pbd/enumwriter.h17
2 files changed, 19 insertions, 6 deletions
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 <string>
#include <vector>
#include <exception>
-
+#include <sstream>
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 {