mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 20:14:23 +08:00
Add an internal helper for logging (upcoming).
PiperOrigin-RevId: 452134803 Change-Id: I8660df850ab537c441399545b25eb32399b2a3ef
This commit is contained in:
committed by
Copybara-Service
parent
b957f0ccd0
commit
a567153787
@@ -69,6 +69,15 @@ struct StatusRep {
|
||||
};
|
||||
|
||||
absl::StatusCode MapToLocalCode(int value);
|
||||
|
||||
// If `status` is not OK, returns a pointer to a newly-allocated string with the
|
||||
// given `prefix`, suitable for output as an error message in assertion/CHECK()
|
||||
// failures. Otherwise returns nullptr.
|
||||
//
|
||||
// This is an internal implementation detail for Abseil logging.
|
||||
std::string* MakeCheckFailString(const absl::Status& status,
|
||||
const char* prefix);
|
||||
|
||||
} // namespace status_internal
|
||||
|
||||
ABSL_NAMESPACE_END
|
||||
|
||||
@@ -599,5 +599,17 @@ Status ErrnoToStatus(int error_number, absl::string_view message) {
|
||||
MessageForErrnoToStatus(error_number, message));
|
||||
}
|
||||
|
||||
namespace status_internal {
|
||||
|
||||
std::string* MakeCheckFailString(const absl::Status& status,
|
||||
const char* prefix) {
|
||||
if (status.ok()) { return nullptr; }
|
||||
return new std::string(
|
||||
absl::StrCat(prefix, " (",
|
||||
status.ToString(StatusToStringMode::kWithEverything), ")"));
|
||||
}
|
||||
|
||||
} // namespace status_internal
|
||||
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
Reference in New Issue
Block a user