From d159501993cfd0215f94f0e5e16796558417b681 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 8 May 2008 02:19:44 -0400 Subject: The code is compiling again, but it's far from being able to run yet. --- error.h | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'error.h') diff --git a/error.h b/error.h index 771e9f10..3c11d2cd 100644 --- a/error.h +++ b/error.h @@ -2,6 +2,7 @@ #define _ERROR_H #include +#include #include #include #include @@ -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 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::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() {} }; -- cgit v1.2.3