Library APIs return OrthoResult<T>, whose error is an Arc<OrthoError>.
Propagate it while loading, then render or map it where the application owns
the user experience:
use ortho_config::{OrthoConfig, OrthoError};
use serde::Deserialize;
#[derive(Debug, Deserialize, OrthoConfig)]
struct Config {
port: u16,
}
fn main() {
match Config::load_from_iter(["acme", "--port", "not-a-number"]) {
Ok(config) => println!("port={}", config.port),
Err(error) => match error.as_ref() {
OrthoError::CliParsing(clap_error) => eprintln!("{clap_error}"),
other => eprintln!("configuration error: {other}"),
},
}
}
Preserve clap's display-only exits for --help and --version; use
is_display_request when a wider application error layer needs to distinguish
them. OrthoError::try_aggregate combines independent validation failures
without inventing an error for an empty collection. The result extension traits
OrthoResultExt, OrthoMergeExt, and ResultIntoFigment keep conversions
explicit at integration boundaries.