blob: d15c5f6f93e8d6f2a82a17860d0046da57ea54b3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#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 <class T>
typename TOptionalTraits<T>::TOptional FindAttribute(const TError& error, TStringBuf key)
{
return error.Attributes().Find<T>(key);
}
template <class T>
typename TOptionalTraits<T>::TOptional FindAttributeRecursive(const TError& error, TStringBuf key)
{
auto attr = FindAttribute<T>(error, key);
if (TOptionalTraits<T>::HasValue(attr)) {
return attr;
}
for (const auto& inner : error.InnerErrors()) {
attr = FindAttribute<T>(inner, key);
if (TOptionalTraits<T>::HasValue(attr)) {
return attr;
}
}
return TOptionalTraits<T>::Empty();
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|