X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fexcept.cpp;fp=source%2Fexcept.cpp;h=eea692e06fd6ee042a3732a52f4ee5fcb96812a8;hp=0000000000000000000000000000000000000000;hb=ed78b585cfc4ecb44972e346857e887b183fd7a7;hpb=0ea5e96f078d85fe4229784e6499d19c67271219 diff --git a/source/except.cpp b/source/except.cpp new file mode 100644 index 0000000..eea692e --- /dev/null +++ b/source/except.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include "except.h" + +using namespace std; + +namespace Msp { +namespace DataFile { + +data_error::data_error(const string &s, unsigned l, const string &w): + runtime_error(make_what(s, l, w)), + source(s), + line(l) +{ } + +data_error::data_error(const string &s, unsigned l, const exception &e): + runtime_error(make_what(s, l, format("%s (%s)", Debug::demangle(typeid(e).name()), e.what()))), + source(s), + line(l) +{ } + +string data_error::make_what(const string &s, unsigned l, const string &w) +{ + if(l) + return format("%s:%d: %s", s, l, w); + else + return format("%s: %s", s, w); +} + + +parse_error::parse_error(const string &t): + runtime_error(t.empty() ? "at end of input" : format("after '%s'", t)) +{ } + + +syntax_error::syntax_error(const string &t): + runtime_error(t.empty() ? "at end of input" : format("at '%s'", t)) +{ } + + +bad_definition::bad_definition(const string &w): + runtime_error(w) +{ } + + +nesting_error::nesting_error(const string &w): + logic_error(w) +{ } + +} // namespace DataFile +} // namespace Msp