aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarkady-e1ppa <arkady-e1ppa@yandex-team.com>2024-05-06 10:47:41 +0300
committerarkady-e1ppa <arkady-e1ppa@yandex-team.com>2024-05-06 10:56:20 +0300
commit932c96fa924d9afc28d0170c3e63d5e22776613d (patch)
treef11abd3d05ca850039fb69d02cca75c534548068
parentea3609653a3f09a516e0f81fc4503bfc641cc84a (diff)
downloadydb-932c96fa924d9afc28d0170c3e63d5e22776613d.tar.gz
YT-21466: SlotManager alerts refactoring
First attempt 9a711025745004e3b8c228570b0ca2dbf2875e99
-rw-r--r--yt/yt/core/misc/error-inl.h15
-rw-r--r--yt/yt/core/misc/error.h11
2 files changed, 17 insertions, 9 deletions
diff --git a/yt/yt/core/misc/error-inl.h b/yt/yt/core/misc/error-inl.h
index a2c45dbdcd..fbb66a4926 100644
--- a/yt/yt/core/misc/error-inl.h
+++ b/yt/yt/core/misc/error-inl.h
@@ -196,28 +196,31 @@ TErrorOr<T>& TErrorOr<T>::operator = (TErrorOr<T>&& other) noexcept
}
template <class T>
-T&& TErrorOr<T>::ValueOrThrow() &&
+template <class... TArgs>
+T&& TErrorOr<T>::ValueOrThrow(TArgs&&... args) &&
{
if (!IsOK()) {
- THROW_ERROR std::move(*this);
+ THROW_ERROR std::move(*this).Wrap(std::forward<TArgs>(args)...);
}
return std::move(*Value_);
}
template <class T>
-T& TErrorOr<T>::ValueOrThrow() &
+template <class... TArgs>
+T& TErrorOr<T>::ValueOrThrow(TArgs&&... args) &
{
if (!IsOK()) {
- THROW_ERROR *this;
+ THROW_ERROR Wrap(std::forward<TArgs>(args)...);
}
return *Value_;
}
template <class T>
-const T& TErrorOr<T>::ValueOrThrow() const &
+template <class... TArgs>
+const T& TErrorOr<T>::ValueOrThrow(TArgs&&... args) const &
{
if (!IsOK()) {
- THROW_ERROR *this;
+ THROW_ERROR Wrap(std::forward<TArgs>(args)...);
}
return *Value_;
}
diff --git a/yt/yt/core/misc/error.h b/yt/yt/core/misc/error.h
index b9ec4a31ab..87686b0544 100644
--- a/yt/yt/core/misc/error.h
+++ b/yt/yt/core/misc/error.h
@@ -403,9 +403,14 @@ public:
T& Value() &;
T&& Value() &&;
- const T& ValueOrThrow() const &;
- T& ValueOrThrow() &;
- T&& ValueOrThrow() &&;
+ template <class... TArgs>
+ const T& ValueOrThrow(TArgs&&... args) const &;
+
+ template <class... TArgs>
+ T& ValueOrThrow(TArgs&&... args) &;
+
+ template <class... TArgs>
+ T&& ValueOrThrow(TArgs&&... args) &&;
const T& ValueOrDefault(const T& defaultValue) const &;
T& ValueOrDefault(T& defaultValue) &;