Skip to content
Commit 1e99b178 authored by Mårten Kongstad's avatar Mårten Kongstad Committed by Todd Kennedy
Browse files

idmap2: introduce improved Result class

Add a new version of the Result class that functions like the old
Result, but in case of an error, also encodes a string detailing the
error. This will allow us to write the following type of code:

Result<Foo> CreateFoo() {
    if (...) {
        return Error("errno=%d", errno());
    }
    return Foo(...);
}

auto foo = CreateFoo();
if (!foo) {
    std::cerr << "error: " << foo.GetErrorMessage() << std::endl;
    abort();
}
std::cout << "foo=" << *foo << std::endl;

This commit only adds the new Result class. A later change will replace
uses of the old version.

Test: make idmap2_tests
Change-Id: I674d8a06866402adedf85f8514400f25840d5eda
parent 598a0eba
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment