summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/error/error.h
diff options
context:
space:
mode:
authorAlexander Smirnov <[email protected]>2025-05-07 00:51:54 +0000
committerAlexander Smirnov <[email protected]>2025-05-07 00:51:54 +0000
commit459ec323afa65de40887e0a1f55ef659056ac91a (patch)
tree973dbba7523bfe215b6ca826fa6c0523e9bff0c9 /library/cpp/yt/error/error.h
parentdc5fb6e978b430a30e6259533a9501c0121e7b17 (diff)
parent59e4896597a08373565093494c534c4e5ca5bdad (diff)
Merge branch 'rightlib' into merge-libs-250507-0050
Diffstat (limited to 'library/cpp/yt/error/error.h')
-rw-r--r--library/cpp/yt/error/error.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/library/cpp/yt/error/error.h b/library/cpp/yt/error/error.h
index 92f19bc398a..4b329105bcb 100644
--- a/library/cpp/yt/error/error.h
+++ b/library/cpp/yt/error/error.h
@@ -219,13 +219,20 @@ public:
template <CErrorNestable TValue>
TError operator << (const std::optional<TValue>& rhs) const &;
- // The |enricher| is called during TError construction and before TErrorOr<> construction. Meant
- // to enrich the error, e.g. by setting generic attributes. The |RegisterEnricher| method is not
+ // The |enricher| is called during TError initial construction and before TErrorOr<> construction. Meant
+ // to enrich the error, e.g. by setting generic attributes. Copying TError from another TError or TErrorException
+ // doesn't call enrichers. The |RegisterEnricher| method is not
// threadsafe and is meant to be called from single-threaded bootstrapping code. Multiple
// enrichers are supported and will be called in order of registration.
- using TEnricher = std::function<void(TError&)>;
+ using TEnricher = std::function<void(TError*)>;
static void RegisterEnricher(TEnricher enricher);
+ // The |enricher| is called during TError every construction from std::exception (including TErrorException).
+ // The |RegisterFromExceptionEnricher| method is not threadsafe and is meant to be called from single-threaded
+ // bootstrapping code. Multiple enrichers are supported and will be called in order of registration.
+ using TFromExceptionEnricher = std::function<void(TError*, const std::exception&)>;
+ static void RegisterFromExceptionEnricher(TFromExceptionEnricher enricher);
+
private:
class TImpl;
std::unique_ptr<TImpl> Impl_;
@@ -234,10 +241,12 @@ private:
void MakeMutable();
void Enrich();
+ void EnrichFromException(const std::exception& exception);
friend class TErrorAttributes;
static TEnricher Enricher_;
+ static TFromExceptionEnricher FromExceptionEnricher_;
};
////////////////////////////////////////////////////////////////////////////////