n0_error/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! Ergonomic error handling with call-site location tracking.
//!
//! This crate provides tools for efficient and ergonomic error handling with support
//! for tracking the call-site location of errors.
//!
//! Inspired by anyhow, thiserror, and snafu.

#![doc = include_str!("../README.md")]
#![deny(missing_docs)]

pub use n0_error_macros::{Error, add_meta};

extern crate self as n0_error;

mod any;
mod error;
mod ext;
mod macros;
mod meta;
#[cfg(test)]
mod tests;

pub use self::{any::*, error::*, ext::*, macros::*, meta::*};

/// `Result` type alias where the error type defaults to [`AnyError`].
pub type Result<T = (), E = AnyError> = std::result::Result<T, E>;

/// Returns a result with the error type set to [`AnyError`].
///
/// Equivalent to `Ok::<_, AnyError>(value)`.
#[allow(non_snake_case)]
pub fn Ok<T>(value: T) -> Result<T, AnyError> {
    std::result::Result::Ok(value)
}