diff --git a/luna/include/luna/Result.h b/luna/include/luna/Result.h index b012ffab..38143c7e 100644 --- a/luna/include/luna/Result.h +++ b/luna/include/luna/Result.h @@ -90,6 +90,13 @@ template class Result return m_value.try_set_value(ref); } + Result try_set_value_with_specific_error(T& ref, int error) + { + if (has_error() && m_error != error) return release_error(); + + return m_value.try_set_value(ref); + } + T release_value() { expect(has_value(), "Result::release_value() called on a Result that holds an error");