MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / expectedValueOrThrow

Function expectedValueOrThrow

source/MRPython/MRPython.h:237–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235// Like `e.value()`, but throws using `throwExceptionFromExpected` (which is better, because it allows Python to see the proper error message), and also supports `T == void`.
236template <typename T>
237[[nodiscard]] decltype(auto) expectedValueOrThrow( T&& e )
238{
239 if ( e )
240 {
241 if constexpr ( std::is_void_v<typename std::remove_cvref_t<T>::value_type> )
242 return;
243 else
244 return *std::forward<T>( e );
245 }
246 else
247 {
248 throwExceptionFromExpected( e.error() );
249 }
250}
251
252template<typename R, typename E, typename... Args>
253auto decorateExpected( std::function<Expected<R, E>( Args... )>&& f ) -> std::function<R( Args... )>

Callers 3

readValueFunction · 0.85
writeValueFunction · 0.85

Calls 2

errorMethod · 0.80

Tested by

no test coverage detected