Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::Error Struct Reference

One uniform error record. More...

#include <error.hpp>

Public Member Functions

bool is_error () const noexcept
bool is_warning () const noexcept
bool is_cancellation () const noexcept
std::string to_string () const
 Stable single-line render: <kind>:<source>:<key>: <message>.

Static Public Member Functions

static Error validation (ValidationKey k, std::string msg)
 Hard validation error.
static Error validation_warning (ValidationKey k, std::string msg)
 Soft validation advisory (severity = Warning).
static Error async_failure (std::string msg, std::string source_tag="AsyncCommand", std::exception_ptr inner={})
 Async failure with optional inner exception_ptr preserved.
static Error cancellation (std::string source_tag="AsyncCommand")
 Cancellation.
static Error timeout (std::string source_tag="AsyncCommand")
 with_timeout deadline expired.
static Error user_error (std::string msg, std::string source_tag={})
 Bad caller argument (mirrors std::invalid_argument / std::out_of_range).
static Error graph_cycle (std::string msg, std::exception_ptr inner={})
 Reactive graph cycle (mirrors CircularDependencyError).
static Error from_exception (std::exception_ptr ex, std::string source_tag)
 Catch-all converter from a thrown exception_ptr to a typed Error.

Public Attributes

ErrorKind kind = ErrorKind::AsyncFailure
Severity severity = Severity::Error
std::string message
std::string source
 Free-form locator: which subsystem produced this.
ValidationKey key
 For kind == Validation: the (field_path, rule_id) locator.
std::exception_ptr inner
 Optional original exception.

Detailed Description

One uniform error record.

Consumed by every observable error face in the framework (AsyncCommand::last_error, AsyncResource::error, ValidationState::errors, ...).

Member Function Documentation

◆ is_error()

bool aria::Error::is_error ( ) const
inlinenodiscardnoexcept

◆ is_warning()

bool aria::Error::is_warning ( ) const
inlinenodiscardnoexcept

◆ is_cancellation()

bool aria::Error::is_cancellation ( ) const
inlinenodiscardnoexcept

◆ to_string()

std::string aria::Error::to_string ( ) const
inlinenodiscard

Stable single-line render: <kind>:<source>:<key>: <message>.

Useful for log lines and GraphInspector traces.

◆ validation()

Error aria::Error::validation ( ValidationKey k,
std::string msg )
inlinestaticnodiscard

Hard validation error.

Callers usually go through Validator/FormValidator, which build these for them.

◆ validation_warning()

Error aria::Error::validation_warning ( ValidationKey k,
std::string msg )
inlinestaticnodiscard

Soft validation advisory (severity = Warning).

◆ async_failure()

Error aria::Error::async_failure ( std::string msg,
std::string source_tag = "AsyncCommand",
std::exception_ptr inner = {} )
inlinestaticnodiscard

Async failure with optional inner exception_ptr preserved.

◆ cancellation()

Error aria::Error::cancellation ( std::string source_tag = "AsyncCommand")
inlinestaticnodiscard

Cancellation.

Always Severity::Error (consumers can opt to render it as nothing). Source tag defaults to "AsyncCommand" because that is by far the most common emitter.

◆ timeout()

Error aria::Error::timeout ( std::string source_tag = "AsyncCommand")
inlinestaticnodiscard

with_timeout deadline expired.

◆ user_error()

Error aria::Error::user_error ( std::string msg,
std::string source_tag = {} )
inlinestaticnodiscard

Bad caller argument (mirrors std::invalid_argument / std::out_of_range).

◆ graph_cycle()

Error aria::Error::graph_cycle ( std::string msg,
std::exception_ptr inner = {} )
inlinestaticnodiscard

Reactive graph cycle (mirrors CircularDependencyError).

◆ from_exception()

Error aria::Error::from_exception ( std::exception_ptr ex,
std::string source_tag )
inlinestaticnodiscard

Catch-all converter from a thrown exception_ptr to a typed Error.

Recognises:

  • std::invalid_argument / std::out_of_range -> UserError
  • std::exception -> AsyncFailure
  • unknown -> AsyncFailure

Aria's own sentinel exception types (OperationCancelled, TimeoutError, CircularDependencyError) are intentionally NOT recognised here, because doing so would force error.hpp to back-include async/cancellation.hpp etc. and reverse the module dependency. Each error-face site (e.g. aria::async::detail::process_async_exception) catches the sentinel first and calls a precise factory (Error::cancellation(), Error::timeout(), Error::graph_cycle()); only the residual reaches from_exception.

source_tag lets the call site annotate "where did this come from"; pick a stable string ("AsyncCommand", "AsyncResource", ...) so consumers can route on it.

Member Data Documentation

◆ kind

ErrorKind aria::Error::kind = ErrorKind::AsyncFailure

◆ severity

Severity aria::Error::severity = Severity::Error

◆ message

std::string aria::Error::message

◆ source

std::string aria::Error::source

Free-form locator: which subsystem produced this.

Stable strings such as "AsyncCommand", "AsyncResource", "Validator", "FormValidator", "Graph", "Binding". Empty if unknown.

◆ key

ValidationKey aria::Error::key

For kind == Validation: the (field_path, rule_id) locator.

Empty for every other kind (still a valid ValidationKey, just with empty strings).

◆ inner

std::exception_ptr aria::Error::inner

Optional original exception.

Most consumers never need it; it is intentionally not part of equality (see operator== below) because exception_ptrs are pointer-identity-compared and that would break observer change detection on no-op resets.


The documentation for this struct was generated from the following file: