Skip to content

Commit

Permalink
Refinement in how clear_current_error is handled
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Sep 4, 2024
1 parent 3422b31 commit 16f1341
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/boost/leaf/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ namespace leaf_detail
{
mutable bool clear_current_error_;

bool is_current_exception() const noexcept
{
return tls::read_uint<leaf_detail::tls_tag_id_factory_current_id>() == error_id::value();
}

error_id get_error_id() const noexcept final override
{
clear_current_error_ = false;
Expand Down Expand Up @@ -143,7 +148,7 @@ namespace leaf_detail

~exception() noexcept
{
if( clear_current_error_ )
if( clear_current_error_ && is_current_exception() )
tls::write_uint<leaf_detail::tls_tag_id_factory_current_id>(0);
}
};
Expand Down

0 comments on commit 16f1341

Please sign in to comment.