Lite version of Status without dependency on protobuf. TODO(b/128867901): Migrate to absl::Status.
| 45 | // Lite version of Status without dependency on protobuf. |
| 46 | // TODO(b/128867901): Migrate to absl::Status. |
| 47 | class Status { |
| 48 | public: |
| 49 | Status() = default; |
| 50 | Status(StatusCode code) : code_(code) {} |
| 51 | Status(StatusCode code, const std::string& error_message) |
| 52 | : code_(code), error_message_(error_message) {} |
| 53 | |
| 54 | const std::string& error_message() const { return error_message_; } |
| 55 | StatusCode code() const { return code_; } |
| 56 | bool ok() const { return code_ == StatusCode::kOk; } |
| 57 | |
| 58 | void IgnoreError() const {} |
| 59 | |
| 60 | private: |
| 61 | StatusCode code_ = StatusCode::kOk; |
| 62 | std::string error_message_; |
| 63 | }; |
| 64 | |
| 65 | #define RETURN_IF_ERROR(status) \ |
| 66 | { \ |
no outgoing calls