Skip to content

Commit 672bfd8

Browse files
committed
docs: fix
1 parent e3d7f3c commit 672bfd8

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# n0-error
22

3-
**Experimental / Work in progress**
3+
An error library that supports tracking the call-site location of errors.
44

5-
A error library that supports tracking the call-site location of errors. Also features an anyhow-style `AnyError`.
5+
This crate provides a trait and proc macro to ergonomically work with enum or struct errors. The macro can add
6+
a `meta` field to structs and enum variants, which stores the call-site location of errors. The `StackError`
7+
trait provides access to this metadata for both the current error, and all its sources, as long as they also
8+
implement `StackError`.
9+
10+
Additionally, this crate provides an anyhow-style `AnyError` type, which is a type-erased container for either
11+
`StackError` or `std::error::Error` errors.
612

713
```rust
814
use n0_error::{e, stack_error, StackError, Result, StackResultExt, StdResultExt};

src/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{ErrorRef, FromString, Meta, SourceFormat, StackError, StackErrorExt}
1212
/// their call-site location info.
1313
///
1414
/// Errors that implement [`std::error::Error`] but not [`StackError`] can't convert to
15-
/// [`AnyError`] automatically. Use either [`AnyError::from_std`] or [`crate::StdResultExt::e`]
15+
/// [`AnyError`] automatically. Use either [`AnyError::from_std`] or [`crate::StdResultExt::anyerr`]
1616
/// to convert std errors into [`AnyError`].
1717
///
1818
/// This is necessary unfortunately because if we had a blanket conversion from std errors to `AnyError`,

src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//! Ergonomic error handling with call-site location tracking.
2-
//!
3-
//! This crate provides tools for efficient and ergonomic error handling with support
4-
//! for tracking the call-site location of errors.
5-
//!
6-
//! Inspired by anyhow, thiserror, and snafu.
7-
81
#![doc = include_str!("../README.md")]
92
#![deny(missing_docs)]
103

src/macros.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ pub use spez as __spez;
4141
/// The forms that take `value` use *autoref specialization* to keep the most details possible:
4242
/// if given a [`StackError`] it uses [`AnyError::from_stack`], if given a std error, uses [`AnyError::from_std`],
4343
/// if given a value that impls `Display` it uses [`AnyError::from_display`] - in this order.
44+
///
45+
/// [`AnyError::context`]: crate::AnyError::context
46+
/// [`AnyError::from_display`]: crate::AnyError::from_display
47+
/// [`AnyError::from_stack`]: crate::AnyError::from_stack
48+
/// [`AnyError::from_std`]: crate::AnyError::from_std
49+
/// [`AnyError`]: crate::AnyError
50+
/// [`StackError`]: crate::StackError
4451
#[macro_export]
4552
macro_rules! anyerr {
4653
($fmt:literal$(, $($arg:expr),* $(,)?)?) => {
@@ -92,6 +99,9 @@ macro_rules! ensure {
9299
/// to `false`, the macro expands to returning an error result. The error will be constructed
93100
/// by passing the remaining arguments after the expression to [`anyerr`]. See its docs for
94101
/// supported forms.
102+
///
103+
/// [`AnyError`]: crate::AnyError
104+
/// [`anyerr`]: crate::anyerr
95105
#[macro_export]
96106
macro_rules! ensure_any {
97107
($cond:expr, $($tt:tt)*) => {
@@ -116,6 +126,9 @@ macro_rules! bail {
116126
///
117127
/// This macro accepts the same forms as [`anyerr`], but wraps the error into `Err` and
118128
/// expands to returning the result from the current function.
129+
///
130+
/// [`AnyError`]: crate::AnyError
131+
/// [`anyerr`]: crate::anyerr
119132
#[macro_export]
120133
macro_rules! bail_any {
121134
($($tt:tt)*) => {
@@ -143,6 +156,8 @@ macro_rules! try_or {
143156
///
144157
/// If the result is the error variant, this will construct a new error with [`anyerr`]
145158
/// from the result's error while providing additional context.
159+
///
160+
/// [`anyerr`]: crate::anyerr
146161
#[macro_export]
147162
macro_rules! try_or_any {
148163
($result:expr, $($context:tt)*) => {

0 commit comments

Comments
 (0)