9 #include <boost/format.hpp>
11 /* Before 4.7, gcc's std::exception uses empty throw() specifiers for
12 * its (virtual) destructor and what() in c++11 mode, in violation of spec
15 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
16 #define EXCEPTION_NEEDS_THROW_SPEC
24 /* Inherit some names from other namespaces for convenience. */
35 FormatOrString(const string
& s
) : s(s
) { };
36 FormatOrString(const format
& f
) : s(f
.str()) { };
37 FormatOrString(const char * s
) : s(s
) { };
41 /* BaseError should generally not be caught, as it has Interrupted as
42 a subclass. Catch Error instead. */
43 class BaseError
: public std::exception
46 string prefix_
; // used for location traces etc.
49 unsigned int status
; // exit status
50 BaseError(const FormatOrString
& fs
, unsigned int status
= 1);
51 #ifdef EXCEPTION_NEEDS_THROW_SPEC
52 ~BaseError() throw () { };
53 const char * what() const throw () { return err
.c_str(); }
55 const char * what() const noexcept
{ return err
.c_str(); }
57 const string
& msg() const { return err
; }
58 const string
& prefix() const { return prefix_
; }
59 BaseError
& addPrefix(const FormatOrString
& fs
);
62 #define MakeError(newClass, superClass) \
63 class newClass : public superClass \
66 newClass(const FormatOrString & fs, unsigned int status = 1) : superClass(fs, status) { }; \
69 MakeError(Error
, BaseError
)
71 class SysError
: public Error
75 SysError(const FormatOrString
& fs
);
79 typedef list
<string
> Strings
;
80 typedef set
<string
> StringSet
;
83 /* Paths are just strings. */
85 typedef list
<Path
> Paths
;
86 typedef set
<Path
> PathSet
;