error_helpers-inl.h 1014 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef ERROR_HELPERS_INL_H_
  2. #error "Direct inclusion of this file is not allowed, include error_helpers.h"
  3. // For the sake of sane code completion.
  4. #include "error_helpers.h"
  5. #endif
  6. namespace NYT {
  7. ////////////////////////////////////////////////////////////////////////////////
  8. template <class T>
  9. typename TOptionalTraits<T>::TOptional FindAttribute(const TError& error, TStringBuf key)
  10. {
  11. return error.Attributes().Find<T>(key);
  12. }
  13. template <class T>
  14. typename TOptionalTraits<T>::TOptional FindAttributeRecursive(const TError& error, TStringBuf key)
  15. {
  16. auto attr = FindAttribute<T>(error, key);
  17. if (TOptionalTraits<T>::HasValue(attr)) {
  18. return attr;
  19. }
  20. for (const auto& inner : error.InnerErrors()) {
  21. attr = FindAttribute<T>(inner, key);
  22. if (TOptionalTraits<T>::HasValue(attr)) {
  23. return attr;
  24. }
  25. }
  26. return TOptionalTraits<T>::Empty();
  27. }
  28. ////////////////////////////////////////////////////////////////////////////////
  29. } // namespace NYT