mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
* Some refactoring of the exception handling code so that we can catch
Nix expression assertion failures.
This commit is contained in:
parent
fa72ae1e9c
commit
9088dee9e2
5 changed files with 45 additions and 22 deletions
|
@ -25,6 +25,13 @@ Error::Error(const format & f)
|
|||
}
|
||||
|
||||
|
||||
Error & Error::addPrefix(const format & f)
|
||||
{
|
||||
err = f.str() + err;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
SysError::SysError(const format & f)
|
||||
: Error(format("%1%: %2%") % f.str() % strerror(errno))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue