diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-13 00:42:25 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-13 00:42:25 -0400 |
commit | 40f553228f5a28034c6635fdcb4c86af28a385ed (patch) | |
tree | 2c40305c9f9841a4c3d453a4a5c49ec69056b4b2 /src/error.h | |
parent | 556211e623cad88213e5087b5c9c36e754d9aa02 (diff) | |
parent | b1b4e2aadff5983d443d70c09ea86a41b015873f (diff) | |
download | fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.tar.gz fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.tar.bz2 fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.zip |
Merge branch 'next'
Diffstat (limited to 'src/error.h')
-rw-r--r-- | src/error.h | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/error.h b/src/error.h index 0d33f020..b9960b03 100644 --- a/src/error.h +++ b/src/error.h @@ -51,52 +51,54 @@ extern std::ostringstream _desc_buffer; template <typename T> inline void throw_func(const string& message) { + _desc_buffer.clear(); _desc_buffer.str(""); throw T(message); } -#define throw_(cls, msg) \ - ((_desc_buffer << ACCUM(_desc_accum << msg)), \ - _desc_accum.clear(), \ +#define throw_(cls, msg) \ + ((_desc_buffer << ACCUM(_desc_accum << msg)), \ + _desc_accum.clear(), \ throw_func<cls>(_desc_buffer.str())) inline void warning_func(const string& message) { std::cerr << "Warning: " << message << std::endl; + _desc_buffer.clear(); _desc_buffer.str(""); } -#define warning_(msg) \ - ((_desc_buffer << ACCUM(_desc_accum << msg)), \ - _desc_accum.clear(), \ +#define warning_(msg) \ + ((_desc_buffer << ACCUM(_desc_accum << msg)), \ + _desc_accum.clear(), \ warning_func(_desc_buffer.str())) -extern straccstream _ctxt_accum; +extern straccstream _ctxt_accum; extern std::ostringstream _ctxt_buffer; -#define add_error_context(msg) \ - ((long(_ctxt_buffer.tellp()) == 0) ? \ - ((_ctxt_buffer << ACCUM(_ctxt_accum << msg)), \ - _ctxt_accum.clear()) : \ - ((_ctxt_buffer << std::endl << ACCUM(_ctxt_accum << msg)), \ +#define add_error_context(msg) \ + ((long(_ctxt_buffer.tellp()) == 0) ? \ + ((_ctxt_buffer << ACCUM(_ctxt_accum << msg)), \ + _ctxt_accum.clear()) : \ + ((_ctxt_buffer << std::endl << ACCUM(_ctxt_accum << msg)), \ _ctxt_accum.clear())) string error_context(); string file_context(const path& file, std::size_t line); -string line_context(const string& line, - const string::size_type pos = 0, - const string::size_type end_pos = 0); - -string source_context(const path& file, - const istream_pos_type pos, - const istream_pos_type end_pos, - const string& prefix = ""); - -#define DECLARE_EXCEPTION(name, kind) \ - class name : public kind { \ - public: \ - explicit name(const string& why) throw() : kind(why) {} \ - virtual ~name() throw() {} \ +string line_context(const string& line, + const string::size_type pos = 0, + const string::size_type end_pos = 0); + +string source_context(const path& file, + const istream_pos_type pos, + const istream_pos_type end_pos, + const string& prefix = ""); + +#define DECLARE_EXCEPTION(name, kind) \ + class name : public kind { \ + public: \ + explicit name(const string& why) throw() : kind(why) {} \ + virtual ~name() throw() {} \ } } // namespace ledger |