From faaa4cdc9ba80774714004652b681b1deae26fe8 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 15 Aug 2020 14:52:15 +0200 Subject: [PATCH] Make C Interface return stack. --- CInterface/Core.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index 3a2d0c7..7acd1fc 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -4,6 +4,7 @@ #include #include #include +#include "../src/Exception.hpp" #define export extern "C" #define ArbutilsException 3; @@ -12,6 +13,9 @@ class ExceptionHandler { static std::string _ArbutilsLastException; public: + static void SetLastException(const ArbUt::Exception& e) { + _ArbutilsLastException = std::string(e.what()) + "\n" + e.GetStacktrace(); + } static void SetLastException(const std::exception& e) { _ArbutilsLastException = std::string(e.what()); } static const char* GetLastException() { return _ArbutilsLastException.c_str(); } }; @@ -20,6 +24,9 @@ public: try { \ data; \ return 0; \ + } catch (const ArbUt::Exception& e) { \ + ExceptionHandler::SetLastException(e); \ + return ArbutilsException; \ } catch (const std::exception& e) { \ ExceptionHandler::SetLastException(e); \ return ArbutilsException; \