summaryrefslogtreecommitdiff
path: root/src/error.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-02 00:23:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-02 00:23:02 -0400
commit5d9015a3c1f3b52acb8299b6eb5e27e176c3f0a4 (patch)
treea824a8279e40a30ea4fdb5178f9189d4d31b1ddd /src/error.h
parentfb5428ce85127413da6cba184dda178352a82b3c (diff)
downloadfork-ledger-5d9015a3c1f3b52acb8299b6eb5e27e176c3f0a4.tar.gz
fork-ledger-5d9015a3c1f3b52acb8299b6eb5e27e176c3f0a4.tar.bz2
fork-ledger-5d9015a3c1f3b52acb8299b6eb5e27e176c3f0a4.zip
Moved error code into error.h.
Diffstat (limited to 'src/error.h')
-rw-r--r--src/error.h41
1 files changed, 6 insertions, 35 deletions
diff --git a/src/error.h b/src/error.h
index 0f128b4e..d61490aa 100644
--- a/src/error.h
+++ b/src/error.h
@@ -65,43 +65,14 @@ extern std::ostringstream _ctxt_buffer;
((long(_ctxt_buffer.tellp()) == 0) ? \
(_ctxt_buffer << msg) : (_ctxt_buffer << std::endl << msg))
-inline string error_context() {
- string context = _ctxt_buffer.str();
- _ctxt_buffer.str("");
- return context;
-}
-
-inline string file_context(const path& file, std::size_t line) {
- std::ostringstream buf;
- buf << "\"" << file << "\", line " << line << ": ";
- return buf.str();
-}
+string error_context();
-inline string line_context(const string& line,
- istream_pos_type pos = istream_pos_type(0),
- istream_pos_type end_pos = istream_pos_type(0))
-{
- std::ostringstream buf;
- buf << " " << line << "\n";
+string file_context(const path& file, std::size_t line);
+string line_context(const string& line,
+ istream_pos_type pos = istream_pos_type(0),
+ istream_pos_type end_pos = istream_pos_type(0));
- if (pos != istream_pos_type(0)) {
- buf << " ";
- if (end_pos == istream_pos_type(0)) {
- for (istream_pos_type i = 0; i < pos; i += 1)
- buf << " ";
- buf << "^\n";
- } else {
- for (istream_pos_type i = 0; i < end_pos; i += 1) {
- if (i >= pos)
- buf << "^";
- else
- buf << " ";
- }
- buf << '\n';
- }
- }
- return buf.str();
-}
+void report_error(const std::exception& err);
#define DECLARE_EXCEPTION(name, kind) \
class name : public kind { \