libcryfs/fuse/FuseErrnoException.h

44 lines
861 B
C
Raw Normal View History

#pragma once
2015-10-15 13:04:57 +02:00
#ifndef MESSMER_FSPP_FUSE_FUSEERRNOEXCEPTION_H_
#define MESSMER_FSPP_FUSE_FUSEERRNOEXCEPTION_H_
#include <stdexcept>
#include <errno.h>
#include <messmer/cpp-utils/assert/assert.h>
2014-11-16 00:05:28 +01:00
namespace fspp {
namespace fuse{
class FuseErrnoException: public std::runtime_error {
public:
explicit FuseErrnoException(int errno_);
virtual ~FuseErrnoException();
int getErrno() const;
private:
int _errno;
};
inline void CHECK_RETVAL(int retval) {
if (retval < 0) {
throw FuseErrnoException(errno);
}
}
2014-11-16 00:58:46 +01:00
inline FuseErrnoException::FuseErrnoException(int errno_)
:runtime_error(strerror(errno_)), _errno(errno_) {
ASSERT(_errno != 0, "Errno shouldn't be zero");
2014-11-16 00:58:46 +01:00
}
inline FuseErrnoException::~FuseErrnoException() {
}
inline int FuseErrnoException::getErrno() const {
return _errno;
}
}
}
2014-11-16 00:05:28 +01:00
#endif /* FSPP_FUSE_FUSEERRNOEXCEPTION_H_ */