aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/yexception.h
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-02-10 16:46:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:31 +0300
commit317da38588b7898a99fd9168571408123350012b (patch)
tree25eebc31526019ad39a6c1b13f492963d97ba439 /util/generic/yexception.h
parent3b2241461d41d41ba1a706b0750c4f0f55c344f6 (diff)
downloadydb-317da38588b7898a99fd9168571408123350012b.tar.gz
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/yexception.h')
-rw-r--r--util/generic/yexception.h82
1 files changed, 41 insertions, 41 deletions
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index b0c604e8c4..b7e93c06da 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -1,6 +1,6 @@
#pragma once
-#include "bt_exception.h"
+#include "bt_exception.h"
#include "strbuf.h"
#include "string.h"
#include "utility.h"
@@ -140,18 +140,18 @@ struct TBadCastException: public virtual TBadArgumentException {
#define ythrow throw __LOCATION__ +
-namespace NPrivate {
- /// Encapsulates data for one of the most common case in which
- /// exception message contists of single constant string
- struct TSimpleExceptionMessage {
- TSourceLocation Location;
- TStringBuf Message;
- };
-
+namespace NPrivate {
+ /// Encapsulates data for one of the most common case in which
+ /// exception message contists of single constant string
+ struct TSimpleExceptionMessage {
+ TSourceLocation Location;
+ TStringBuf Message;
+ };
+
[[noreturn]] void ThrowYException(const TSimpleExceptionMessage& sm);
- [[noreturn]] void ThrowYExceptionWithBacktrace(const TSimpleExceptionMessage& sm);
-}
-
+ [[noreturn]] void ThrowYExceptionWithBacktrace(const TSimpleExceptionMessage& sm);
+}
+
void fputs(const std::exception& e, FILE* f = stderr);
TString CurrentExceptionMessage();
@@ -182,24 +182,24 @@ TString FormatExc(const std::exception& exception);
} \
} while (false)
-/// @def Y_ENSURE_SIMPLE
-/// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view.
-/// Should not be used directly.
-#define Y_ENSURE_SIMPLE(CONDITION, MESSAGE, THROW_FUNCTION) \
- do { \
- if (Y_UNLIKELY(!(CONDITION))) { \
- /* use variable to guarantee evaluation at compile time */ \
- static constexpr const ::NPrivate::TSimpleExceptionMessage __SIMPLE_EXCEPTION_MESSAGE{__LOCATION__, (MESSAGE)}; \
- THROW_FUNCTION(__SIMPLE_EXCEPTION_MESSAGE); \
- } \
- } while (false)
-
+/// @def Y_ENSURE_SIMPLE
+/// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view.
+/// Should not be used directly.
+#define Y_ENSURE_SIMPLE(CONDITION, MESSAGE, THROW_FUNCTION) \
+ do { \
+ if (Y_UNLIKELY(!(CONDITION))) { \
+ /* use variable to guarantee evaluation at compile time */ \
+ static constexpr const ::NPrivate::TSimpleExceptionMessage __SIMPLE_EXCEPTION_MESSAGE{__LOCATION__, (MESSAGE)}; \
+ THROW_FUNCTION(__SIMPLE_EXCEPTION_MESSAGE); \
+ } \
+ } while (false)
+
#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException)
#define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE)
#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace)
-#define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE)
-
+#define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE)
+
/**
* @def Y_ENSURE
*
@@ -214,18 +214,18 @@ TString FormatExc(const std::exception& exception);
* @endcode
*/
#define Y_ENSURE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_IMPL_2, Y_ENSURE_IMPL_1)(__VA_ARGS__))
-
-/**
- * @def Y_ENSURE_BT
- *
- * This macro is inteded to use as a shortcut for `if () { throw TWithBackTrace<yexception>() << "message"; }`.
- *
- * @code
- * void DoSomethingLovely(const int x, const int y) {
- * Y_ENSURE_BT(x > y, "`x` must be greater than `y`");
- * Y_ENSURE_BT(x > y); // if you are too lazy
- * // actually doing something nice here
- * }
- * @endcode
- */
-#define Y_ENSURE_BT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_BT_IMPL_2, Y_ENSURE_BT_IMPL_1)(__VA_ARGS__))
+
+/**
+ * @def Y_ENSURE_BT
+ *
+ * This macro is inteded to use as a shortcut for `if () { throw TWithBackTrace<yexception>() << "message"; }`.
+ *
+ * @code
+ * void DoSomethingLovely(const int x, const int y) {
+ * Y_ENSURE_BT(x > y, "`x` must be greater than `y`");
+ * Y_ENSURE_BT(x > y); // if you are too lazy
+ * // actually doing something nice here
+ * }
+ * @endcode
+ */
+#define Y_ENSURE_BT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_BT_IMPL_2, Y_ENSURE_BT_IMPL_1)(__VA_ARGS__))