Place util exceptions in the util namespace

This commit is contained in:
Danny Robson 2012-05-16 15:01:01 +10:00
parent c6a3831840
commit 6e82915975
2 changed files with 33 additions and 31 deletions

View File

@ -25,6 +25,7 @@
#include <cerrno> #include <cerrno>
using namespace std; using namespace std;
using namespace util;
/// Construct an errno_error from a given error value. The error value MUST signal an error at /// Construct an errno_error from a given error value. The error value MUST signal an error at

View File

@ -26,51 +26,52 @@
#include <stdexcept> #include <stdexcept>
class input_error : public std::runtime_error { namespace util {
public: class input_error : public std::runtime_error {
input_error (const std::string &_what): public:
input_error (const std::string &_what):
runtime_error (_what) runtime_error (_what)
{ ; } { ; }
}; };
class unavailable_error : public std::runtime_error { class unavailable_error : public std::runtime_error {
public: public:
unavailable_error (const std::string &_what): unavailable_error (const std::string &_what):
runtime_error (_what) runtime_error (_what)
{ ; } { ; }
}; };
/// An exception class used for reporting errors signalled by errno. /// An exception class used for reporting errors signalled by errno.
class errno_error : public std::runtime_error { class errno_error : public std::runtime_error {
public: public:
int id; int id;
errno_error (int _errno); errno_error (int _errno);
errno_error (); errno_error ();
static void try_code (void); static void try_code (void);
static void try_code (int code); static void try_code (int code);
static void throw_code (void); static void throw_code (void);
static void throw_code (int code); static void throw_code (int code);
}; };
#if defined(PLATFORM_WIN32) #if defined(PLATFORM_WIN32)
#include <windows.h> #include <windows.h>
class win32_error : public std::runtime_error { class win32_error : public std::runtime_error {
public: public:
DWORD id; DWORD id;
win32_error (DWORD _id); win32_error (DWORD _id);
win32_error (); win32_error ();
static void try_code (void); static void try_code (void);
static void throw_code (void); static void throw_code (void);
}; };
#endif #endif
}
#endif #endif