google / google/leveldb

Make leveldb::Status::code() and corresponding enum public or at least protected

Open
#677 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

Boost 1.70 ships boost::outcome, which is a type that stores value or error_code. Arbitrary enums can be registered as error_codes (https://boostorg.github.io/outcome/motivation/plug_error_code.html).

In our project we use leveldb and Boost 1.70 and we'd like to get value of `leveldb::Status::code()` directly, so we can register it as error_code and then use something like
```c++
outcome::result open(std::string_view path) {
auto status = leveldb::DB::Open(this->options, path, &db);
return status.code();
}
```

instead of ugly if-chain:
```c++
outcome::result open(std::string_view path) {
auto status = leveldb::DB::Open(this->options, path, &db);
if(status.IsIOError()){
return outcome::failure(kIOError); // yes, we copied your enum in our code, because it is private :(
}
...
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.