Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f8698f8

Browse files
authored
Make fml/status_or.h compatible with .clang_tidy. (#48002)
Work towards flutter/flutter#134969.
1 parent 27fe2c3 commit f8698f8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

fml/status_or.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ namespace fml {
3131
template <typename T>
3232
class StatusOr {
3333
public:
34+
// These constructors are intended be compatible with absl::status_or.
35+
// NOLINTNEXTLINE(google-explicit-constructor)
3436
StatusOr(const T& value) : status_(), value_(value) {}
37+
38+
// These constructors are intended be compatible with absl::status_or.
39+
// NOLINTNEXTLINE(google-explicit-constructor)
3540
StatusOr(const Status& status) : status_(status), value_() {}
3641

3742
StatusOr(const StatusOr&) = default;
@@ -63,13 +68,19 @@ class StatusOr {
6368
bool ok() const { return status_.ok(); }
6469

6570
const T& value() const {
66-
FML_CHECK(status_.ok());
67-
return value_.value();
71+
if (status_.ok()) {
72+
return value_.value();
73+
}
74+
FML_LOG(FATAL) << "StatusOr::value() called on error Status";
75+
FML_UNREACHABLE();
6876
}
6977

7078
T& value() {
71-
FML_CHECK(status_.ok());
72-
return value_.value();
79+
if (status_.ok()) {
80+
return value_.value();
81+
}
82+
FML_LOG(FATAL) << "StatusOr::value() called on error Status";
83+
FML_UNREACHABLE();
7384
}
7485

7586
private:

0 commit comments

Comments
 (0)