From 03719682937dcb3a1e8bcf69225ffce5c526d06d Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 15 Nov 2023 18:08:56 -0800 Subject: [PATCH] Make `fml/status_or.h` compatible with `.clang_tidy`. (flutter/engine#48002) Work towards https://github.com/flutter/flutter/issues/134969. --- engine/src/flutter/fml/status_or.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/fml/status_or.h b/engine/src/flutter/fml/status_or.h index 080b836c05..537878fff6 100644 --- a/engine/src/flutter/fml/status_or.h +++ b/engine/src/flutter/fml/status_or.h @@ -31,7 +31,12 @@ namespace fml { template class StatusOr { public: + // These constructors are intended be compatible with absl::status_or. + // NOLINTNEXTLINE(google-explicit-constructor) StatusOr(const T& value) : status_(), value_(value) {} + + // These constructors are intended be compatible with absl::status_or. + // NOLINTNEXTLINE(google-explicit-constructor) StatusOr(const Status& status) : status_(status), value_() {} StatusOr(const StatusOr&) = default; @@ -63,13 +68,19 @@ class StatusOr { bool ok() const { return status_.ok(); } const T& value() const { - FML_CHECK(status_.ok()); - return value_.value(); + if (status_.ok()) { + return value_.value(); + } + FML_LOG(FATAL) << "StatusOr::value() called on error Status"; + FML_UNREACHABLE(); } T& value() { - FML_CHECK(status_.ok()); - return value_.value(); + if (status_.ok()) { + return value_.value(); + } + FML_LOG(FATAL) << "StatusOr::value() called on error Status"; + FML_UNREACHABLE(); } private: