sapling/eden/fs/rocksdb/RocksException.h
Andres Suarez fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00

44 lines
1.1 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/String.h>
#include <rocksdb/db.h>
namespace facebook {
namespace eden {
class RocksException : public std::exception {
public:
RocksException(const rocksdb::Status& status, const std::string& msg);
template <typename... Args>
static RocksException build(const rocksdb::Status& status, Args&&... args) {
return RocksException(
status, folly::to<std::string>(std::forward<Args>(args)...));
}
template <typename... Args>
static void check(const rocksdb::Status& status, Args&&... args) {
if (UNLIKELY(!status.ok())) {
throw build(status, std::forward<Args>(args)...);
}
}
const char* what() const noexcept override;
const rocksdb::Status& getStatus() const;
const std::string& getMsg() const;
private:
rocksdb::Status status_;
std::string msg_;
std::string fullMsg_;
};
} // namespace eden
} // namespace facebook