2014-11-15 15:16:18 +01:00
|
|
|
#pragma once
|
2014-11-16 00:05:28 +01:00
|
|
|
#ifndef FSPP_FUSE_FUSEERRNOEXCEPTION_H_
|
|
|
|
#define FSPP_FUSE_FUSEERRNOEXCEPTION_H_
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
namespace fspp {
|
2014-11-28 14:46:45 +01:00
|
|
|
namespace fuse{
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
class FuseErrnoException: public std::runtime_error {
|
|
|
|
public:
|
2015-04-27 18:21:33 +02:00
|
|
|
explicit FuseErrnoException(int errno_);
|
2014-11-15 15:16:18 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline FuseErrnoException::~FuseErrnoException() {
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int FuseErrnoException::getErrno() const {
|
|
|
|
return _errno;
|
|
|
|
}
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
}
|
|
|
|
}
|
2014-11-15 15:16:18 +01:00
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
#endif /* FSPP_FUSE_FUSEERRNOEXCEPTION_H_ */
|