Fix error logging

This commit is contained in:
Sebastian Messmer 2018-04-15 21:37:06 -07:00
parent 3047ec229d
commit 706ef263c9
3 changed files with 5 additions and 12 deletions

View File

@ -14,7 +14,7 @@ if(NOT BUILD_TESTING)
set(BUILD_TESTING OFF CACHE BOOL "BUILD_TESTING") set(BUILD_TESTING OFF CACHE BOOL "BUILD_TESTING")
endif(NOT BUILD_TESTING) endif(NOT BUILD_TESTING)
# Default vaule is to build in release mode # Default value is to build in release mode
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE INTERNAL "CMAKE_BUILD_TYPE") set(CMAKE_BUILD_TYPE Release CACHE INTERNAL "CMAKE_BUILD_TYPE")
endif(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE)

View File

@ -4,27 +4,20 @@
#include <cpp-utils/macros.h> #include <cpp-utils/macros.h>
#include <string> #include <string>
#include <stdexcept>
namespace blockstore { namespace blockstore {
namespace integrity { namespace integrity {
class IntegrityViolationError final : public std::exception { class IntegrityViolationError final : public std::runtime_error {
public:
const char *what() const throw() override {
return _reason.c_str();
}
private: private:
// Constructor is private to make sure that only IntegrityBlockStore can throw this exception. // Constructor is private to make sure that only IntegrityBlockStore can throw this exception.
// This is because IntegrityBlockStore wants to know about integrity violations and // This is because IntegrityBlockStore wants to know about integrity violations and
// block all further file system access if it happens. // block all further file system access if it happens.
IntegrityViolationError(const std::string &reason) IntegrityViolationError(const std::string &reason)
: _reason("Integrity violation: " + reason) { : std::runtime_error("Integrity violation: " + reason) {
} }
friend class IntegrityBlockStore2; friend class IntegrityBlockStore2;
std::string _reason;
}; };

View File

@ -222,7 +222,7 @@ Fuse::Fuse(Filesystem *fs, std::string fstype, boost::optional<std::string> fsna
} }
void Fuse::_logException(const std::exception &e) { void Fuse::_logException(const std::exception &e) {
LOG(ERROR, "Exception thrown: ", e.what()); LOG(ERROR, "Exception thrown: {}", e.what());
} }
void Fuse::_logUnknownException() { void Fuse::_logUnknownException() {