about summary refs log tree commit diff
path: root/src/libutil/util.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-03-08T14·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-03-08T14·11+0000
commit9088dee9e265db8176b61e53ac43a916fdd34a3d (patch)
tree42abd16be1b9bc4e4b5b4defdcd44b5bd9972740 /src/libutil/util.hh
parentfa72ae1e9cad0dded28b965fe97293bbeeac031e (diff)
* Some refactoring of the exception handling code so that we can catch
  Nix expression assertion failures.

Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r--src/libutil/util.hh14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index aac2acd1730b..05cf777f1eb6 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -26,6 +26,7 @@ public:
     ~Error() throw () { };
     const char * what() const throw () { return err.c_str(); }
     const string & msg() const throw () { return err; }
+    Error & addPrefix(const format & f);
 };
 
 class SysError : public Error
@@ -34,11 +35,14 @@ public:
     SysError(const format & f);
 };
 
-class UsageError : public Error
-{
-public:
-    UsageError(const format & f) : Error(f) { };
-};
+#define MakeError(newClass, superClass) \
+    class newClass : public superClass                  \
+    {                                                   \
+    public:                                             \
+        newClass(const format & f) : superClass(f) { }; \
+    };
+
+MakeError(UsageError, Error)
 
 
 typedef list<string> Strings;