-
#include "tensorstore/util/result.h"
- TENSORSTORE_ASSIGN_OR_RETURN(decl, ...);
Convenience macro for propagating errors when calling a function that returns a
tensorstore::Result
.This macro generates multiple statements and should be invoked as follows:
Result<int> GetSomeResult(); TENSORSTORE_ASSIGN_OR_RETURN(int x, GetSomeResult());
An optional third argument specifies the return expression in the case of an error. A variable
_
bound to the errorabsl::Status
value is in scope within this expression. For example:TENSORSTORE_ASSIGN_OR_RETURN(int x, GetSomeResult(), _.Annotate("Context message"));