diff options
author | wconner <wconner@google.com> | 2023-02-14 11:58:09 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-02-14 11:59:18 -0800 |
commit | 2b8434e2abce2f1dec0a7436c0242fe9d5a5092f (patch) | |
tree | 887a423c5c375cfe909a21e86c490896f7595439 /cc/util | |
parent | 6b504e2e44b6ff8056913c24abf718541debcbaf (diff) | |
download | tink-2b8434e2abce2f1dec0a7436c0242fe9d5a5092f.tar.gz |
Replace std::abort/std::exit/std::_Exit with LOG/CHECK macros.
PiperOrigin-RevId: 509597381
Diffstat (limited to 'cc/util')
-rw-r--r-- | cc/util/BUILD.bazel | 2 | ||||
-rw-r--r-- | cc/util/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cc/util/statusor.h | 24 |
3 files changed, 14 insertions, 14 deletions
diff --git a/cc/util/BUILD.bazel b/cc/util/BUILD.bazel index 14118fb3c..c81e3cf48 100644 --- a/cc/util/BUILD.bazel +++ b/cc/util/BUILD.bazel @@ -125,6 +125,8 @@ cc_library( visibility = ["//visibility:public"], deps = [ ":status", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/status:statusor", ], ) diff --git a/cc/util/CMakeLists.txt b/cc/util/CMakeLists.txt index e9c6dd5b8..b42799597 100644 --- a/cc/util/CMakeLists.txt +++ b/cc/util/CMakeLists.txt @@ -64,6 +64,8 @@ tink_cc_library( statusor.h DEPS tink::util::status + absl::check + absl::log absl::statusor PUBLIC ) diff --git a/cc/util/statusor.h b/cc/util/statusor.h index 28cc35e0a..6872cd0fb 100644 --- a/cc/util/statusor.h +++ b/cc/util/statusor.h @@ -21,6 +21,8 @@ #include <iostream> #include <utility> +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/statusor.h" #include "tink/util/status.h" @@ -165,19 +167,16 @@ class StatusOr { private: void EnsureOk() const { if (ABSL_PREDICT_FALSE(!ok())) { - std::cerr << "Attempting to fetch value of non-OK StatusOr\n"; - std::cerr << status() << std::endl; - std::_Exit(1); + LOG(FATAL) << "Attempting to fetch value of non-OK StatusOr\n" + << status(); } } void AbortWithMessageFrom(crypto::tink::util::Status status) const { - std::cerr << "Attempting to fetch value instead of handling error\n"; - std::cerr << status.ToString(); - std::abort(); + LOG(FATAL) << "Attempting to fetch value instead of handling error\n" + << status.ToString(); } - Status status_; absl::optional<T> value_; }; @@ -190,13 +189,10 @@ inline StatusOr<T>::StatusOr() } template <typename T> -inline StatusOr<T>::StatusOr( - const ::crypto::tink::util::Status& status) : status_(status) { - if (status.ok()) { - std::cerr << "::crypto::tink::util::OkStatus() " - << "is not a valid argument to StatusOr\n"; - std::_Exit(1); - } +inline StatusOr<T>::StatusOr(const ::crypto::tink::util::Status& status) + : status_(status) { + CHECK(!status.ok()) << "::crypto::tink::util::OkStatus() " + << "is not a valid argument to StatusOr\n"; } template <typename T> |