37 lines
563 B
C++
37 lines
563 B
C++
#ifndef _EXCEPTIONS_HH_
|
|
#define _EXCEPTIONS_HH_
|
|
|
|
#include <errno.h>
|
|
|
|
namespace ex {
|
|
// An unexcpected fatal error occured
|
|
class error {
|
|
public:
|
|
error(int eno = 0) : eno_(eno) {
|
|
}
|
|
|
|
int getErrno() const {
|
|
return eno_;
|
|
}
|
|
|
|
private:
|
|
int eno_;
|
|
};
|
|
|
|
// A memory allocation, or virtual address space allocation, failed
|
|
class bad_alloc : public error {
|
|
public:
|
|
bad_alloc() : error(ENOMEM) {
|
|
}
|
|
};
|
|
|
|
// An operation timed out
|
|
class timeout : public error {
|
|
public:
|
|
timeout() : error(EAGAIN) {
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif
|