aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/yexception.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/yexception.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/yexception.cpp')
-rw-r--r--util/generic/yexception.cpp86
1 files changed, 43 insertions, 43 deletions
diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp
index 2ce6c4369d..a8ef36bd50 100644
--- a/util/generic/yexception.cpp
+++ b/util/generic/yexception.cpp
@@ -1,19 +1,19 @@
#include "bt_exception.h"
#include "yexception.h"
-
-#include <util/system/backtrace.h>
+
+#include <util/system/backtrace.h>
#include <util/system/type_name.h>
-
+
#include <cxxabi.h>
-#include <stdexcept>
-
-#include <cstdio>
-
-TString FormatExc(const std::exception& exception) {
+#include <stdexcept>
+
+#include <cstdio>
+
+TString FormatExc(const std::exception& exception) {
return TString::Join(TStringBuf("("), TypeName(exception), TStringBuf(") "), exception.what());
-}
-
+}
+
TString CurrentExceptionMessage() {
auto exceptionPtr = std::current_exception();
if (exceptionPtr) {
@@ -21,7 +21,7 @@ TString CurrentExceptionMessage() {
std::rethrow_exception(exceptionPtr);
} catch (const yexception& e) {
const TBackTrace* bt = e.BackTrace();
-
+
if (bt) {
return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e));
}
@@ -30,23 +30,23 @@ TString CurrentExceptionMessage() {
} catch (const std::exception& e) {
return FormatExc(e);
} catch (...) {
- }
-
+ }
+
return "unknown error";
- }
-
+ }
+
return "(NO EXCEPTION)";
-}
-
+}
+
bool UncaughtException() noexcept {
// FIXME: use std::uncaught_exceptions() unconditionally after DEVTOOLS-8811
#if defined(__cpp_lib_uncaught_exceptions) && !defined(_LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS)
return std::uncaught_exceptions() > 0;
#else
- return std::uncaught_exception();
+ return std::uncaught_exception();
#endif
-}
-
+}
+
std::string CurrentExceptionTypeName() {
#if defined(_linux_) || defined(_darwin_)
std::type_info* currentExceptionTypePtr = abi::__cxa_current_exception_type();
@@ -67,18 +67,18 @@ std::string CurrentExceptionTypeName() {
}
}
-void TSystemError::Init() {
- yexception& exc = *this;
-
+void TSystemError::Init() {
+ yexception& exc = *this;
+
exc << TStringBuf("(");
exc << TStringBuf(LastSystemErrorText(Status_));
exc << TStringBuf(") ");
-}
-
+}
+
NPrivateException::yexception::yexception() {
ZeroTerminate();
}
-
+
TStringBuf NPrivateException::yexception::AsStrBuf() const {
if (Buf_.Left()) {
return TStringBuf(Buf_.Data(), Buf_.Filled());
@@ -91,27 +91,27 @@ void NPrivateException::yexception::ZeroTerminate() noexcept {
char* end = (char*)Buf_.Current();
if (!Buf_.Left()) {
- --end;
- }
-
- *end = 0;
-}
-
+ --end;
+ }
+
+ *end = 0;
+}
+
const char* NPrivateException::yexception::what() const noexcept {
return Buf_.Data();
-}
-
+}
+
const TBackTrace* NPrivateException::yexception::BackTrace() const noexcept {
return nullptr;
-}
-
-void fputs(const std::exception& e, FILE* f) {
- char message[256];
- size_t len = Min(sizeof(message) - 2, strlcpy(message, e.what(), sizeof(message) - 1));
- message[len++] = '\n';
- message[len] = 0;
- fputs(message, f);
-}
+}
+
+void fputs(const std::exception& e, FILE* f) {
+ char message[256];
+ size_t len = Min(sizeof(message) - 2, strlcpy(message, e.what(), sizeof(message) - 1));
+ message[len++] = '\n';
+ message[len] = 0;
+ fputs(message, f);
+}
void ::NPrivate::ThrowYException(const ::NPrivate::TSimpleExceptionMessage& sm) {
throw sm.Location + yexception() << sm.Message;