#ifndef ERROR_HELPERS_INL_H_ #error "Direct inclusion of this file is not allowed, include error_helpers.h" // For the sake of sane code completion. #include "error_helpers.h" #endif namespace NYT { //////////////////////////////////////////////////////////////////////////////// template typename TOptionalTraits::TOptional FindAttribute(const TError& error, TStringBuf key) { return error.Attributes().Find(key); } template typename TOptionalTraits::TOptional FindAttributeRecursive(const TError& error, TStringBuf key) { auto attr = FindAttribute(error, key); if (TOptionalTraits::HasValue(attr)) { return attr; } for (const auto& inner : error.InnerErrors()) { attr = FindAttribute(inner, key); if (TOptionalTraits::HasValue(attr)) { return attr; } } return TOptionalTraits::Empty(); } //////////////////////////////////////////////////////////////////////////////// } // namespace NYT