X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fexcept.h;h=cc8c1fbdcd6b3a4f5b303023871d667b66287381;hp=4573e947297dedd3f8311b92842d7f62faa98aa4;hb=3272ce1847cfda26c3f04ba9c7acc8285ddb2230;hpb=aa8bfd3c13848dc27947d3947038bd66c258d288 diff --git a/source/except.h b/source/except.h index 4573e94..cc8c1fb 100644 --- a/source/except.h +++ b/source/except.h @@ -1,33 +1,84 @@ -/* $Id$ +#ifndef MSP_DATAFILE_EXCEPT_H_ +#define MSP_DATAFILE_EXCEPT_H_ -This file is part of libmspdatafile -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ -#ifndef MSP_DATAFILE_ERROR_H_ -#define MSP_DATAFILE_ERROR_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; + public: - TypeError(const std::string &w_): Exception(w_) { } + 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 ParseError: public Exception + +class parse_error: public std::runtime_error { public: - ParseError(const std::string &w_, const std::string &s, unsigned l): Exception(w_), source(s), line(l) { } - const std::string &get_source() const { return source; } - unsigned get_line() const { return line; } - ~ParseError() throw() { } -private: - std::string source; - unsigned line; + 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() { } +}; + + +class unknown_keyword: public std::runtime_error +{ +public: + unknown_keyword(const std::string &); + virtual ~unknown_keyword() throw() { } +}; + + +class invalid_signature: public std::runtime_error +{ +public: + invalid_signature(const std::string &, const std::string &); + virtual ~invalid_signature() throw() { } +}; + + +class no_collection: public std::runtime_error +{ +public: + no_collection(const std::type_info &); }; } // namespace DataFile