diff options
author | John Wiegley <johnw@newartisans.com> | 2008-05-08 02:19:44 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-05-08 02:50:19 -0400 |
commit | d159501993cfd0215f94f0e5e16796558417b681 (patch) | |
tree | b0e2b9e9e707dd3f71683e81b9c9c3a1f8b47f86 /error.h | |
parent | 7ecbf3e125481a02c541f9eb3ed795ac3e245541 (diff) | |
download | fork-ledger-d159501993cfd0215f94f0e5e16796558417b681.tar.gz fork-ledger-d159501993cfd0215f94f0e5e16796558417b681.tar.bz2 fork-ledger-d159501993cfd0215f94f0e5e16796558417b681.zip |
The code is compiling again, but it's far from being able to run yet.
Diffstat (limited to 'error.h')
-rw-r--r-- | error.h | 41 |
1 files changed, 22 insertions, 19 deletions
@@ -2,6 +2,7 @@ #define _ERROR_H #include <exception> +#include <stdexcept> #include <string> #include <cstring> #include <sstream> @@ -12,9 +13,9 @@ namespace ledger { class error_context { public: - std::string desc; + string desc; - error_context(const std::string& _desc) throw() : desc(_desc) {} + error_context(const string& _desc) throw() : desc(_desc) {} virtual ~error_context() throw() {} virtual void describe(std::ostream& out) const throw() { if (! desc.empty()) @@ -25,11 +26,11 @@ class error_context class file_context : public error_context { protected: - std::string file; + path file; unsigned long line; public: - file_context(const std::string& _file, unsigned long _line, - const std::string& desc = "") throw() + file_context(const path& _file, unsigned long _line, + const string& desc = "") throw() : error_context(desc), file(_file), line(_line) {} virtual ~file_context() throw() {} @@ -41,13 +42,14 @@ class file_context : public error_context } }; -class line_context : public error_context { - public: - std::string line; +class line_context : public error_context +{ +public: + string line; long pos; - line_context(const std::string& _line, long _pos, - const std::string& desc = "") throw() + line_context(const string& _line, long _pos, + const string& desc = "") throw() : error_context(desc), line(_line), pos(_pos) {} virtual ~line_context() throw() {} @@ -65,11 +67,12 @@ class line_context : public error_context { ////////////////////////////////////////////////////////////////////// -class str_exception : public std::logic_error { - public: +class str_exception : public std::logic_error +{ +public: std::list<error_context *> context; - str_exception(const std::string& why, + str_exception(const string& why, error_context * ctxt = NULL) throw() : std::logic_error(why) { if (ctxt) @@ -84,7 +87,7 @@ class str_exception : public std::logic_error { } virtual void reveal_context(std::ostream& out, - const std::string& kind) const throw() { + const string& kind) const throw() { for (std::list<error_context *>::const_reverse_iterator i = context.rbegin(); i != context.rend(); @@ -100,28 +103,28 @@ class str_exception : public std::logic_error { #define DECLARE_EXCEPTION(kind, name) \ class name : public kind { \ public: \ - name(const std::string& why, error_context * ctxt = NULL) throw() \ + name(const string& why, error_context * ctxt = NULL) throw() \ : kind(why, ctxt) {} \ } class error : public str_exception { public: - error(const std::string& why, error_context * ctxt = NULL) throw() + error(const string& why, error_context * ctxt = NULL) throw() : str_exception(why, ctxt) {} virtual ~error() throw() {} }; class fatal : public str_exception { public: - fatal(const std::string& why, error_context * ctxt = NULL) throw() + fatal(const string& why, error_context * ctxt = NULL) throw() : str_exception(why, ctxt) {} virtual ~fatal() throw() {} }; class fatal_assert : public fatal { public: - fatal_assert(const std::string& why, error_context * ctxt = NULL) throw() - : fatal(std::string("assertion failed '") + why + "'", ctxt) {} + fatal_assert(const string& why, error_context * ctxt = NULL) throw() + : fatal(string("assertion failed '") + why + "'", ctxt) {} virtual ~fatal_assert() throw() {} }; |