summaryrefslogtreecommitdiff
path: root/value.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-31 06:24:45 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-31 06:24:45 -0400
commit99313ebc6c3779f692f9f1bd70cc69a236f5eb78 (patch)
tree44a553891a9aaa148084d8e011b2d326401343e9 /value.h
parent8afd926a27af55862ce360970e05d747f249a0da (diff)
downloadledger-99313ebc6c3779f692f9f1bd70cc69a236f5eb78.tar.gz
ledger-99313ebc6c3779f692f9f1bd70cc69a236f5eb78.tar.bz2
ledger-99313ebc6c3779f692f9f1bd70cc69a236f5eb78.zip
Revised the way that exceptions are thrown around. Instead of context being a
complicated string of pointers, it's now just a global block of text that gets appended to as the error is being thrown up, and can be displayed at the catch point if desired. There are almost no cases where a thrown exception will not result in an error message being displayed to the user.
Diffstat (limited to 'value.h')
-rw-r--r--value.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/value.h b/value.h
index 6bcce319..35a44828 100644
--- a/value.h
+++ b/value.h
@@ -48,6 +48,8 @@
namespace ledger {
+DECLARE_EXCEPTION(value_error, std::runtime_error);
+
/**
* @class value_t
*
@@ -880,18 +882,14 @@ inline std::ostream& operator<<(std::ostream& out, const value_t& val) {
return out;
}
-class value_context : public error_context
-{
- value_t bal;
- public:
- value_context(const value_t& _bal, const string& desc = "") throw()
- : error_context(desc), bal(_bal) {}
- virtual ~value_context() throw() {}
-
- virtual void describe(std::ostream& out) const throw();
-};
-
-DECLARE_EXCEPTION(error, value_error);
+inline string value_context(const value_t& val) {
+ std::ostringstream buf;
+ buf << std::right;
+ buf.width(20);
+ val.print(buf);
+ buf << std::endl;
+ return buf.str();
+}
} // namespace ledger