aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authortrenin17 <trenin17@yandex-team.ru>2022-02-10 16:51:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:51:09 +0300
commit7d9e9dd650ccaad923d6b1ce79baaa3a15b740ae (patch)
tree9c42d6cb3c90f951425e1d63ce484ad67e0936e7 /util
parent9a82582baef5f5fc12d0448b66bdb6576fbb1dd2 (diff)
downloadydb-7d9e9dd650ccaad923d6b1ce79baaa3a15b740ae.tar.gz
Restoring authorship annotation for <trenin17@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/generic/yexception.cpp44
-rw-r--r--util/generic/yexception.h4
-rw-r--r--util/generic/yexception_ut.cpp128
3 files changed, 88 insertions, 88 deletions
diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp
index 2ce6c4369d..8cc8ed250b 100644
--- a/util/generic/yexception.cpp
+++ b/util/generic/yexception.cpp
@@ -4,8 +4,8 @@
#include <util/system/backtrace.h>
#include <util/system/type_name.h>
-#include <cxxabi.h>
-
+#include <cxxabi.h>
+
#include <stdexcept>
#include <cstdio>
@@ -47,26 +47,26 @@ bool UncaughtException() noexcept {
#endif
}
-std::string CurrentExceptionTypeName() {
-#if defined(_linux_) || defined(_darwin_)
- std::type_info* currentExceptionTypePtr = abi::__cxa_current_exception_type();
- if (currentExceptionTypePtr) {
- return TypeName(*currentExceptionTypePtr);
- }
-#endif
- //There is no abi::__cxa_current_exception_type() on Windows.
- //Emulated it with rethrow - catch construction.
- std::exception_ptr currentException = std::current_exception();
- Y_ASSERT(currentException != nullptr);
- try {
- std::rethrow_exception(currentException);
- } catch (const std::exception& e) {
- return TypeName(typeid(e));
- } catch (...) {
- return "unknown type";
- }
-}
-
+std::string CurrentExceptionTypeName() {
+#if defined(_linux_) || defined(_darwin_)
+ std::type_info* currentExceptionTypePtr = abi::__cxa_current_exception_type();
+ if (currentExceptionTypePtr) {
+ return TypeName(*currentExceptionTypePtr);
+ }
+#endif
+ //There is no abi::__cxa_current_exception_type() on Windows.
+ //Emulated it with rethrow - catch construction.
+ std::exception_ptr currentException = std::current_exception();
+ Y_ASSERT(currentException != nullptr);
+ try {
+ std::rethrow_exception(currentException);
+ } catch (const std::exception& e) {
+ return TypeName(typeid(e));
+ } catch (...) {
+ return "unknown type";
+ }
+}
+
void TSystemError::Init() {
yexception& exc = *this;
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index b0c604e8c4..d0a9428ace 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -13,7 +13,7 @@
#include <util/system/defaults.h>
#include <util/system/error.h>
#include <util/system/src_location.h>
-#include <util/system/platform.h>
+#include <util/system/platform.h>
#include <exception>
@@ -171,7 +171,7 @@ TString CurrentExceptionMessage();
*/
bool UncaughtException() noexcept;
-std::string CurrentExceptionTypeName();
+std::string CurrentExceptionTypeName();
TString FormatExc(const std::exception& exception);
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index cb3e29fed8..77b26b9c25 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -52,7 +52,7 @@ class TExceptionTest: public TTestBase {
UNIT_TEST(TestMacroOverload)
UNIT_TEST(TestMessageCrop)
UNIT_TEST(TestTIoSystemErrorSpecialMethods)
- UNIT_TEST(TestCurrentExceptionTypeNameMethod)
+ UNIT_TEST(TestCurrentExceptionTypeNameMethod)
UNIT_TEST_SUITE_END();
private:
@@ -319,74 +319,74 @@ private:
errMoveAssign = std::move(errMove);
UNIT_ASSERT(errMoveAssign.AsStrBuf().Contains(testStr));
}
- inline void TestCurrentExceptionTypeNameMethod() {
- //Basic test of getting the correct exception type name.
- try {
- throw std::runtime_error("Test Runtime Error Exception");
- } catch (...) {
- UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::runtime_error");
- }
- //Test when exception has an unusual type. Under Linux it should return "int" and under other OSs "unknown type".
- try {
- throw int(1);
- } catch (...) {
+ inline void TestCurrentExceptionTypeNameMethod() {
+ //Basic test of getting the correct exception type name.
+ try {
+ throw std::runtime_error("Test Runtime Error Exception");
+ } catch (...) {
+ UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::runtime_error");
+ }
+ //Test when exception has an unusual type. Under Linux it should return "int" and under other OSs "unknown type".
+ try {
+ throw int(1);
+ } catch (...) {
#if defined(LIBCXX_BUILDING_LIBCXXRT) || defined(LIBCXX_BUILDING_LIBGCC)
- UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int");
-#else
- UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type");
-#endif
- }
- //Test when the caught exception is rethrown with std::rethrow_exception.
- try {
- throw std::logic_error("Test Logic Error Exception");
- } catch (...) {
- try {
- std::rethrow_exception(std::current_exception());
- } catch (...) {
- UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::logic_error");
- }
- }
- //Test when the caught exception is rethrown with throw; .
+ UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int");
+#else
+ UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type");
+#endif
+ }
+ //Test when the caught exception is rethrown with std::rethrow_exception.
+ try {
+ throw std::logic_error("Test Logic Error Exception");
+ } catch (...) {
+ try {
+ std::rethrow_exception(std::current_exception());
+ } catch (...) {
+ UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::logic_error");
+ }
+ }
+ //Test when the caught exception is rethrown with throw; .
//This test is different from the previous one because of the interaction with cxxabi specifics.
- try {
- throw std::bad_alloc();
- } catch (...) {
- try {
- throw;
- } catch (...) {
- UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::bad_alloc");
- }
- }
+ try {
+ throw std::bad_alloc();
+ } catch (...) {
+ try {
+ throw;
+ } catch (...) {
+ UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::bad_alloc");
+ }
+ }
// For exceptions thrown by std::rethrow_exception() a nullptr will be returned by libcxxrt's __cxa_current_exception_type().
- // Adding an explicit test for the case.
- try {
- throw int(1);
- } catch (...) {
- try {
- std::rethrow_exception(std::current_exception());
- } catch (...) {
+ // Adding an explicit test for the case.
+ try {
+ throw int(1);
+ } catch (...) {
+ try {
+ std::rethrow_exception(std::current_exception());
+ } catch (...) {
#if defined(LIBCXX_BUILDING_LIBGCC)
- UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int");
-#else
- UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type");
-#endif
- }
- }
- //Test when int is rethrown with throw; .
- try {
- throw int(1);
- } catch (...) {
- try {
- throw;
- } catch (...) {
+ UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int");
+#else
+ UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type");
+#endif
+ }
+ }
+ //Test when int is rethrown with throw; .
+ try {
+ throw int(1);
+ } catch (...) {
+ try {
+ throw;
+ } catch (...) {
#if defined(LIBCXX_BUILDING_LIBCXXRT) || defined(LIBCXX_BUILDING_LIBGCC)
- UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int");
-#else
- UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type");
-#endif
- }
- }
- }
+ UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int");
+#else
+ UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type");
+#endif
+ }
+ }
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TExceptionTest);