2014-11-15 15:16:18 +01:00
|
|
|
#pragma once
|
2015-10-15 13:04:57 +02:00
|
|
|
#ifndef MESSMER_FSPP_FUSE_FUSEERRNOEXCEPTION_H_
|
|
|
|
#define MESSMER_FSPP_FUSE_FUSEERRNOEXCEPTION_H_
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <errno.h>
|
2015-07-22 13:48:34 +02:00
|
|
|
#include <messmer/cpp-utils/assert/assert.h>
|
2014-11-15 15:16:18 +01:00
|
|
|
|
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_) {
|
2015-07-22 13:48:34 +02:00
|
|
|
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-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_ */
|