]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/except.h
Move all exception classes to a common header
[libs/datafile.git] / source / except.h
diff --git a/source/except.h b/source/except.h
new file mode 100644 (file)
index 0000000..e68ec48
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef MSP_DATAFILE_EXCEPT_H_
+#define MSP_DATAFILE_EXCEPT_H_
+
+#include <stdexcept>
+
+namespace Msp {
+namespace DataFile {
+
+class data_error: public std::runtime_error
+{
+private:
+       std::string source;
+       unsigned line;
+
+public:
+       data_error(const std::string &, unsigned, const std::string &);
+       data_error(const std::string &, unsigned, const std::exception &);
+       virtual ~data_error() throw() { }
+
+       const std::string &get_source() const { return source; }
+       unsigned get_line() const { return line; }
+
+private:
+       std::string make_what(const std::string &, unsigned, const std::string &);
+};
+
+
+class parse_error: public std::runtime_error
+{
+public:
+       parse_error(const std::string &);
+       virtual ~parse_error() throw() { }
+};
+
+
+class syntax_error: public std::runtime_error
+{
+public:
+       syntax_error(const std::string &t);
+       virtual ~syntax_error() throw() { }
+};
+
+
+class bad_definition: public std::runtime_error
+{
+public:
+       bad_definition(const std::string &w);
+       virtual ~bad_definition() throw() { }
+};
+
+
+class nesting_error: public std::logic_error
+{
+public:
+       nesting_error(const std::string &);
+       virtual ~nesting_error() throw() { }
+};
+
+} // namespace DataFile
+} // namespace Msp
+
+#endif