From 7eb683b76358542cc1f0c005934c6499f17e3408 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Wed, 13 May 2026 08:38:06 +0200 Subject: [PATCH 1/5] fix(Exception): updating throw_lippincott to OpenGeodeException --- include/geode/basic/assert.hpp | 26 +++++++++++++++++++++++++- src/geode/basic/assert.cpp | 23 ----------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/include/geode/basic/assert.hpp b/include/geode/basic/assert.hpp index d6104af23..fa7feec9d 100644 --- a/include/geode/basic/assert.hpp +++ b/include/geode/basic/assert.hpp @@ -152,5 +152,29 @@ namespace geode /*! * Catch all exceptions and rethrow an OpenGeodeException */ - void opengeode_basic_api throw_lippincott(); + template < typename Exception, typename... Args > + void throw_lippincott( + OpenGeodeException::TYPE type, const Args&... message ) + { + { + try + { + throw; + } + catch( OpenGeodeException& exception ) + { + Exception new_exception{ exception.data(), type, message... }; + new_exception.set_parent( std::move( exception ) ); + } + catch( const std::exception& exception ) + { + throw Exception{ nullptr, type, "std::exception, ", + exception.what() }; + } + catch( ... ) + { + throw Exception{ nullptr, type, "Unknown exception" }; + } + } + } } // namespace geode diff --git a/src/geode/basic/assert.cpp b/src/geode/basic/assert.cpp index b8b352edc..2917e6766 100644 --- a/src/geode/basic/assert.cpp +++ b/src/geode/basic/assert.cpp @@ -105,27 +105,4 @@ namespace geode } return 1; } - - void throw_lippincott() - { - try - { - throw; - } - catch( const OpenGeodeException& /*unused*/ ) - { - throw; - } - catch( const std::exception& exception ) - { - throw OpenGeodeBasicException{ nullptr, - OpenGeodeException::TYPE::internal, "std::exception, ", - exception.what() }; - } - catch( ... ) - { - throw OpenGeodeBasicException{ nullptr, - OpenGeodeException::TYPE::internal, "Unknown exception" }; - } - } } // namespace geode From e2783a017778be3e28978e1aeb872ff7db97af4e Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Wed, 13 May 2026 08:40:11 +0200 Subject: [PATCH 2/5] fix --- include/geode/basic/assert.hpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/include/geode/basic/assert.hpp b/include/geode/basic/assert.hpp index fa7feec9d..398edb11c 100644 --- a/include/geode/basic/assert.hpp +++ b/include/geode/basic/assert.hpp @@ -156,25 +156,23 @@ namespace geode void throw_lippincott( OpenGeodeException::TYPE type, const Args&... message ) { + try { - try - { - throw; - } - catch( OpenGeodeException& exception ) - { - Exception new_exception{ exception.data(), type, message... }; - new_exception.set_parent( std::move( exception ) ); - } - catch( const std::exception& exception ) - { - throw Exception{ nullptr, type, "std::exception, ", - exception.what() }; - } - catch( ... ) - { - throw Exception{ nullptr, type, "Unknown exception" }; - } + throw; + } + catch( OpenGeodeException& exception ) + { + Exception new_exception{ exception.data(), type, message... }; + new_exception.set_parent( std::move( exception ) ); + } + catch( const std::exception& exception ) + { + throw Exception{ nullptr, type, "std::exception, ", + exception.what() }; + } + catch( ... ) + { + throw Exception{ nullptr, type, "Unknown exception" }; } } } // namespace geode From 884e3bb37819192bcb19fb301e2ab4d49089423c Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Wed, 13 May 2026 08:45:11 +0200 Subject: [PATCH 3/5] udpate --- include/geode/basic/assert.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/geode/basic/assert.hpp b/include/geode/basic/assert.hpp index 398edb11c..033acd045 100644 --- a/include/geode/basic/assert.hpp +++ b/include/geode/basic/assert.hpp @@ -164,15 +164,24 @@ namespace geode { Exception new_exception{ exception.data(), type, message... }; new_exception.set_parent( std::move( exception ) ); + throw new_exception; } catch( const std::exception& exception ) { - throw Exception{ nullptr, type, "std::exception, ", - exception.what() }; + Exception new_exception{ nullptr, type, message... }; + OpenGeodeBaiscException std_exception{ nullptr, + OpenGeodeException::TYPE::internal, + "std::exception: ", exception.what() }; + new_exception.set_parent( std::move( std_exception ) ); + throw new_exception; } catch( ... ) { - throw Exception{ nullptr, type, "Unknown exception" }; + Exception new_exception{ nullptr, type, message... }; + OpenGeodeBaiscException unknown_exception{ nullptr, + OpenGeodeException::TYPE::internal, "Unknown exception" }; + new_exception.set_parent( std::move( unknown_exception ) ); + throw new_exception; } } } // namespace geode From 2d0b60bc278b2d8296dd79f494175cfea0b4fb2b Mon Sep 17 00:00:00 2001 From: Pierre Anquez Date: Wed, 13 May 2026 09:05:50 +0200 Subject: [PATCH 4/5] update --- include/geode/basic/assert.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/geode/basic/assert.hpp b/include/geode/basic/assert.hpp index 033acd045..148eb3537 100644 --- a/include/geode/basic/assert.hpp +++ b/include/geode/basic/assert.hpp @@ -153,7 +153,7 @@ namespace geode * Catch all exceptions and rethrow an OpenGeodeException */ template < typename Exception, typename... Args > - void throw_lippincott( + [[noreturn]] void throw_lippincott( OpenGeodeException::TYPE type, const Args&... message ) { try @@ -169,7 +169,7 @@ namespace geode catch( const std::exception& exception ) { Exception new_exception{ nullptr, type, message... }; - OpenGeodeBaiscException std_exception{ nullptr, + Exception std_exception{ nullptr, OpenGeodeException::TYPE::internal, "std::exception: ", exception.what() }; new_exception.set_parent( std::move( std_exception ) ); @@ -178,7 +178,7 @@ namespace geode catch( ... ) { Exception new_exception{ nullptr, type, message... }; - OpenGeodeBaiscException unknown_exception{ nullptr, + Exception unknown_exception{ nullptr, OpenGeodeException::TYPE::internal, "Unknown exception" }; new_exception.set_parent( std::move( unknown_exception ) ); throw new_exception; From 7731ac9870a0298a2385f39170eb5c0054d0943a Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Wed, 13 May 2026 14:07:21 +0200 Subject: [PATCH 5/5] make exception copyable --- include/geode/basic/assert.hpp | 23 ++++-------------- src/geode/basic/assert.cpp | 43 ++++++++++++++++------------------ 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/include/geode/basic/assert.hpp b/include/geode/basic/assert.hpp index 148eb3537..9428ce027 100644 --- a/include/geode/basic/assert.hpp +++ b/include/geode/basic/assert.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -52,10 +51,6 @@ namespace geode */ class opengeode_basic_api OpenGeodeException : public std::runtime_error { - static constexpr int MAX_STACK_DEPTH = 10; - static constexpr int NB_SKIPPED_STACKS = 1; - static constexpr int SYMBOL_SIZE = 1024; - public: enum struct TYPE : std::uint8_t { @@ -65,10 +60,11 @@ namespace geode }; OpenGeodeException( OpenGeodeException&& ) = default; - OpenGeodeException( const OpenGeodeException& ) = delete; - OpenGeodeException& operator=( const OpenGeodeException& ) = delete; OpenGeodeException& operator=( OpenGeodeException&& ) = default; + OpenGeodeException& operator=( const OpenGeodeException& ); + OpenGeodeException( const OpenGeodeException& ); + ~OpenGeodeException() noexcept override; [[nodiscard]] TYPE type() const @@ -93,8 +89,6 @@ namespace geode return data_; } - [[nodiscard]] std::string stack_trace() const; - [[nodiscard]] bool has_parent() const { return parent_ != nullptr; @@ -107,8 +101,8 @@ namespace geode void set_parent( OpenGeodeException&& parent ) { - parent_ = - std::make_unique< OpenGeodeException >( std::move( parent ) ); + parent_ = std::make_unique< OpenGeodeException >( + std::forward< OpenGeodeException >( parent ) ); } [[nodiscard]] std::string string() const; @@ -126,11 +120,6 @@ namespace geode library_{ std::move( library ) }, data_{ std::move( data ) } { - stack_.fill( nullptr ); -#ifndef NDEBUG - stack_size_ = absl::GetStackTrace( - stack_.data(), MAX_STACK_DEPTH, NB_SKIPPED_STACKS ); -#endif } private: @@ -138,8 +127,6 @@ namespace geode std::string project_; std::string library_; std::any data_; - std::array< void*, MAX_STACK_DEPTH > stack_; - int stack_size_{ 0 }; std::unique_ptr< OpenGeodeException > parent_; }; diff --git a/src/geode/basic/assert.cpp b/src/geode/basic/assert.cpp index 2917e6766..d1da5f1dc 100644 --- a/src/geode/basic/assert.cpp +++ b/src/geode/basic/assert.cpp @@ -25,13 +25,30 @@ #include -#include - #include #include namespace geode { + OpenGeodeException::OpenGeodeException( const OpenGeodeException& other ) + : std::runtime_error{ other }, + type_{ other.type_ }, + project_{ other.project_ }, + library_{ other.library_ }, + data_{ other.data_ }, + parent_{ other.parent_ ? std::make_unique< OpenGeodeException >( + *other.parent_ ) + : nullptr } + { + } + + OpenGeodeException& OpenGeodeException::operator=( + const OpenGeodeException& other ) + { + *this = OpenGeodeException{ other }; + return *this; + } + OpenGeodeException::~OpenGeodeException() noexcept = default; std::string_view OpenGeodeException::type_name() const @@ -51,31 +68,11 @@ namespace geode return "unknown"; } - std::string OpenGeodeException::stack_trace() const - { - std::string stack_string; - for( auto frame = 0; frame < stack_size_; ++frame ) - { - absl::StrAppend( &stack_string, " ", frame, ": " ); - if( std::array< char, SYMBOL_SIZE > symbol; absl::Symbolize( - stack_[frame], symbol.data(), sizeof( symbol ) ) ) - { - absl::StrAppend( &stack_string, symbol.data() ); - } - else - { - absl::StrAppend( &stack_string, "Unknown" ); - } - absl::StrAppend( &stack_string, "\n" ); - } - return stack_string; - } - std::string OpenGeodeException::string() const { return absl::StrCat( "OpenGeodeException of type ", type_name(), " from project ", project(), " and library ", library(), ": ", - what(), "\n", stack_trace() ); + what() ); } int geode_lippincott()