X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexcept.h;h=8357c7e33b8ce5d25f9d03c4557869cd52dab48e;hb=83971ed7f55794a61e1d249c59867184a6eb97ba;hp=ff256a4449c0a0eef903857ccfc3312dc4f79569;hpb=7df5e45c7f414f6a07681dc4ec2abb63b091a309;p=libs%2Fdatafile.git diff --git a/source/except.h b/source/except.h index ff256a4..8357c7e 100644 --- a/source/except.h +++ b/source/except.h @@ -1,21 +1,85 @@ #ifndef MSP_DATAFILE_EXCEPT_H_ #define MSP_DATAFILE_EXCEPT_H_ -#include +#include +#include +#include namespace Msp { namespace DataFile { -class TypeError: public Exception +class data_error: public std::runtime_error +{ +private: + std::string source; + unsigned line = 0; + +public: + data_error(const std::string &, unsigned, const std::string &); + data_error(const std::string &, unsigned, const std::exception &); + data_error(const std::string &, unsigned, const data_error &); + ~data_error() throw() override = default; + + 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 &); + ~parse_error() throw() override = default; +}; + + +class syntax_error: public std::runtime_error +{ +public: + syntax_error(const std::string &t); + ~syntax_error() throw() override = default; +}; + + +class bad_definition: public std::runtime_error { public: - TypeError(const std::string &w): Exception(w) { } + bad_definition(const std::string &w); + ~bad_definition() throw() override = default; }; -class ParseError: public Exception + +class nesting_error: public std::logic_error +{ +public: + nesting_error(const std::string &); + ~nesting_error() throw() override = default; +}; + + +class unknown_keyword: public std::runtime_error +{ +public: + unknown_keyword(const std::string &); + ~unknown_keyword() throw() override = default; +}; + + +class invalid_signature: public std::runtime_error +{ +public: + invalid_signature(const std::string &, const std::string &); + ~invalid_signature() throw() override = default; +}; + + +class no_collection: public std::runtime_error { public: - ParseError(const std::string &w): Exception(w) { } + no_collection(const std::type_info &); }; } // namespace DataFile