X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexcept.h;h=3ae83465496b4bc3d050840f6541e04a941c4f18;hb=refs%2Fheads%2Fwip;hp=7892db5be1c292a34ff9c239d0d309b937f708fb;hpb=256f7238bc60d6dcc31a564988f5cc02a60c4537;p=libs%2Fdatafile.git diff --git a/source/except.h b/source/except.h index 7892db5..3ae8346 100644 --- a/source/except.h +++ b/source/except.h @@ -1,28 +1,79 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_DATAFILE_EXCEPT_H_ #define MSP_DATAFILE_EXCEPT_H_ -#include +#include +#include +#include +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { -class TypeError: public Exception +class MSPDATAFILE_API 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 &); + + 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 MSPDATAFILE_API parse_error: public std::runtime_error +{ +public: + parse_error(const std::string &); +}; + + +class MSPDATAFILE_API syntax_error: public std::runtime_error +{ +public: + syntax_error(const std::string &t); +}; + + +class MSPDATAFILE_API bad_definition: public std::runtime_error +{ +public: + bad_definition(const std::string &w); +}; + + +class MSPDATAFILE_API nesting_error: public std::logic_error +{ +public: + nesting_error(const std::string &); +}; + + +class MSPDATAFILE_API unknown_keyword: public std::runtime_error { public: - TypeError(const std::string &w): Exception(w) { } + unknown_keyword(const std::string &); }; -class ParseError: public Exception + +class MSPDATAFILE_API invalid_signature: public std::runtime_error +{ +public: + invalid_signature(const std::string &, const std::string &); +}; + + +class MSPDATAFILE_API no_collection: public std::runtime_error { public: - ParseError(const std::string &w): Exception(w) { } + no_collection(const std::type_info &); }; } // namespace DataFile