Skip to navigation

holoscan::Error

Beta
View as Markdown

Lightweight error value for the expected<T, Error> return path.

Error is the value type to return (via holoscan::expected / make_unexpected) when reporting a recoverable failure, as opposed to throwing. It is intentionally cheap: it carries an ErrorCode and an optional message, and allocates only when the message is non-empty. The common “code only” case (e.g. returning kNotReady / kBackpressured from a hot polling path) performs no allocation, in contrast to RuntimeError, which (as a std::runtime_error) always copies its message into a heap buffer and carries exception RTTI.

When an empty message is rendered (e.g. by the RuntimeError bridge), error_code_name(code) / the code’s error string is used in its place.

Use RuntimeError when an exception must be thrown; a RuntimeError can be constructed from an Error (see RuntimeError(const Error&)), so throw RuntimeError(result.error()); stays a one-liner.

#include <holoscan/errors.hpp>

Member variables

NameTypeDescription
codeErrorCodeThe error code.
messagestd::stringOptional context. Empty (and allocation-free) for code-only errors.
provenancestd::uint64_tOpaque identity of the originating failure, or zero when absent.