Skip to content

Commit

Permalink
Get the exception type in correct way, both on Linux and on MacOS. (#…
Browse files Browse the repository at this point in the history
…2099)

* Get the exception type in correct way, both on Linux and on MacOS.

Signed-off-by: Tao He <[email protected]>
  • Loading branch information
sighingnow authored Sep 28, 2022
1 parent 0fcc2d8 commit e0a7615
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
33 changes: 27 additions & 6 deletions analytical_engine/core/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#ifndef ANALYTICAL_ENGINE_CORE_ERROR_H_
#define ANALYTICAL_ENGINE_CORE_ERROR_H_

#if !(defined(__GLIBCXX__) || defined(__GLIBCPP__))
#include <cxxabi.h>
#endif

#include <string>

#include "vineyard/graph/utils/error.h" // IWYU pragma: export
Expand Down Expand Up @@ -72,6 +76,23 @@ inline rpc::Code ErrorCodeToProto(vineyard::ErrorCode ec) {
} while (0)
#endif

#ifndef __FRAME_CURRENT_EXCEPTION_TYPENAME
#if defined(__GLIBCXX__) || defined(__GLIBCPP__)
#define __FRAME_CURRENT_EXCEPTION_TYPENAME(var) \
do { \
std::exception_ptr __p = std::current_exception(); \
var = __p ? __p.__cxa_exception_type()->name() : "unknow type"; \
} while (0)
#else
#define __FRAME_CURRENT_EXCEPTION_TYPENAME(var) \
do { \
int __status = 0; \
var = abi::__cxa_demangle(abi::__cxa_current_exception_type()->name(), 0, \
0, &__status); \
} while (0)
#endif
#endif

#ifndef __FRAME_CATCH_AND_ASSIGN_GS_ERROR
#if defined(NDEBUG)
#define __FRAME_CATCH_AND_ASSIGN_GS_ERROR(var, expr) \
Expand All @@ -84,11 +105,11 @@ inline rpc::Code ErrorCodeToProto(vineyard::ErrorCode ec) {
} catch (std::string & ex) { \
__FRAME_MAKE_GS_ERROR(var, vineyard::ErrorCode::kIllegalStateError, ex); \
} catch (...) { \
std::exception_ptr p = std::current_exception(); \
std::string __exception_type; \
__FRAME_CURRENT_EXCEPTION_TYPENAME(__exception_type); \
__FRAME_MAKE_GS_ERROR( \
var, vineyard::ErrorCode::kIllegalStateError, \
std::string("Unknown error occurred: ") + \
(p ? p.__cxa_exception_type()->name() : "null")); \
std::string("Unknown error occurred: ") + __exception_type); \
} \
} while (0)
#else
Expand All @@ -111,11 +132,11 @@ inline rpc::Code ErrorCodeToProto(vineyard::ErrorCode ec) {
} catch (std::string & ex) { \
__FRAME_LOG_GS_ERROR(vineyard::ErrorCode::kIllegalStateError, ex); \
} catch (...) { \
std::exception_ptr p = std::current_exception(); \
std::string __exception_type; \
__FRAME_CURRENT_EXCEPTION_TYPENAME(__exception_type); \
__FRAME_LOG_GS_ERROR( \
vineyard::ErrorCode::kIllegalStateError, \
std::string("Unknown error occurred: ") + \
(p ? p.__cxa_exception_type()->name() : "null")); \
std::string("Unknown error occurred: ") + __exception_type); \
} \
} while (0)
#else
Expand Down
11 changes: 10 additions & 1 deletion k8s/precompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,21 @@ def compute_sig(s):
def cmake_and_make(cmake_commands):
try:
cmake_process = subprocess.run(
cmake_commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True
cmake_commands,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
errors="replace",
universal_newlines=True,
check=True
)
make_process = subprocess.run(
[shutil.which("make"), "-j4"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
errors="replace",
universal_newlines=True,
check=True,
)
shutil.rmtree("CMakeFiles")
Expand Down

0 comments on commit e0a7615

Please sign in to comment.