diff options
Diffstat (limited to 'library/cpp/yt/error/error.h')
| -rw-r--r-- | library/cpp/yt/error/error.h | 15 |
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_; }; //////////////////////////////////////////////////////////////////////////////// |
