libcryfs/fuse/FuseErrnoException.h
2015-02-17 00:48:49 +01:00

43 lines
764 B
C++

#pragma once
#ifndef FSPP_FUSE_FUSEERRNOEXCEPTION_H_
#define FSPP_FUSE_FUSEERRNOEXCEPTION_H_
#include <stdexcept>
#include <errno.h>
namespace fspp {
namespace fuse{
class FuseErrnoException: public std::runtime_error {
public:
FuseErrnoException(int errno_);
virtual ~FuseErrnoException();
int getErrno() const;
private:
int _errno;
};
inline void CHECK_RETVAL(int retval) {
if (retval < 0) {
throw FuseErrnoException(errno);
}
}
inline FuseErrnoException::FuseErrnoException(int errno_)
:runtime_error(strerror(errno_)), _errno(errno_) {
assert(_errno != 0);
}
inline FuseErrnoException::~FuseErrnoException() {
}
inline int FuseErrnoException::getErrno() const {
return _errno;
}
}
}
#endif /* FSPP_FUSE_FUSEERRNOEXCEPTION_H_ */