# oi [![crates.io](https://img.shields.io/crates/v/oi.svg)](https://crates.io/crates/oi) [![docs](https://docs.rs/oi/badge.svg)](http://docs.rs/oi) `oi` provides a location-annotated error type so you can display useful error messages to your users. Error messages without location information are often not actionable, especially when they come from a complex program with many potential sources of errors. Compare an unannotated error: ```sh $ foo No such file or directory (os error 2) ``` …with an annotated error: ```sh $ foo Configuration.toml: No such file or directory (os error 2) ``` `oi` is named after the exclamation, as in [Oi! Oi! Oi!](https://youtu.be/XWLU76o5rEI). Imagine alerting your users to the location of errors: "Oi! 1.2.3.4 is unreachable!" ## usage This crate provides an `Error` type that wraps an error and location, a `Location` trait for error locations, an `ErrAt` trait that extends `Result` with an `err_at` method to annotate err values with locations, and a `Result` type as an alias for the more cumbersome `Result>`: ```rust pub struct Error { pub error: E, pub location: L, } pub trait Location: Debug + Send + Sync + 'static { fn fmt_error(&self, f: &mut Formatter, error: &dyn Fail) -> fmt::Result; } pub trait ErrAt { fn err_at>(self, location: I) -> Result>; } pub type Result = std::result::Result>; ``` `Location` is implemented for `PathBuf` and `SocketAddr`, and can easily be implemented for custom location types. The one required method, `fmt_error`, gives custom types control over how an error-annotated location will be rendered to an error message.