Docs.rs
  • error_tools-0.23.0
    • error_tools 0.23.0
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Homepage
    • Repository
    • crates.io
    • Source
    • Owners
    • Wandalen
    • Dependencies
      • anyhow ~1.0 normal optional
      • thiserror ~1.0 normal optional
      • test_tools ~0.16.0 dev
    • Versions
    • 100% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate error_tools

logo

error_tools0.23.0

  • All Items

Sections

  • Module :: error_tools
    • Basic use-case
    • To add to your project
    • Try out from the repository

Crate Items

  • Re-exports
  • Modules
  • Macros
  • Traits
  • Type Aliases
  • Derive Macros

Crates

  • error_tools

Crate error_tools

Source
Expand description

§Module :: error_tools

experimental rust-status docs.rs Open in Gitpod discord

Basic exceptions handling mechanism.

§Basic use-case

ⓘ
#[ cfg( feature = "enabled" ) ]
fn main()
{
  let err = f1();
  println!( "{err:#?}" );
  // < Err(
  // <    BasicError {
  // <        msg: "Some error",
  // <    },
  // < )
}

#[ cfg( feature = "enabled" ) ]
fn f1() -> error_tools::untyped::Result< () >
{
  let _read = std::fs::read_to_string( "Cargo.toml" )?;
  Err( error_tools::BasicError::new( "Some error" ).into() )
}

§To add to your project

cargo add error_tools

§Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cargo run --example error_tools_trivial

Re-exports§

pub use super::super::error;
pub use super::super::untyped;
pub use super::super::untyped as for_app;
pub use super::super::typed;
pub use super::super::typed as for_lib;
pub use super::assert;
pub use super::typed;
pub use super::untyped;

Modules§

dependency
Namespace with dependencies.
error
Alias for std::error::BasicError.
exposed
Exposed namespace of the module.
orphan
Shared with parent namespace of the module
own
Own namespace of the module.
prelude
Prelude to use essentials: use my_module::prelude::*.
thiserror
github crates-io docs-rs

Macros§

debug_assert_id
Macro asserts that two expressions are identical to each other. Unlike std::assert_eq it is removed from a release build.
debug_assert_identical
Macro asserts that two expressions are identical to each other. Unlike std::assert_eq it is removed from a release build. Alias of debug_assert_id.
debug_assert_ni
Macro asserts that two expressions are not identical to each other. Unlike std::assert_eq it is removed from a release build.
debug_assert_not_identical
Macro asserts that two expressions are not identical to each other. Unlike std::assert_eq it is removed from a release build.

Traits§

ErrWith
This trait allows adding extra context or information to an error, creating a tuple of the additional context and the original error. This is particularly useful for error handling when you want to include more details in the error without losing the original error value.
ErrorTrait
Error is a trait representing the basic expectations for error values, i.e., values of type E in Result<T, E>.

Type Aliases§

ResultWithReport
A type alias for a Result that contains an error which is a tuple of a report and an original error.

Derive Macros§

Error

Results

Settings
Help
    struct
    error_tools::dependency::anyhow::Error
    The Error type, a wrapper around a dynamic error type.
    derive macro
    error_tools::Error
    module
    error_tools::error
    Alias for std::error::BasicError.
    trait
    error_tools::ErrorTrait
    Error is a trait representing the basic expectations for …
    trait
    error_tools::error::ErrorTrait
    Error is a trait representing the basic expectations for …
    trait
    error_tools::error::own::ErrorTrait
    Error is a trait representing the basic expectations for …
    trait
    error_tools::own::ErrorTrait
    Error is a trait representing the basic expectations for …
    extern crate
    error_tools
    Module :: error_tools
    method
    error_tools::error::untyped::Error::is
    &Error -> bool
    Returns true if E is the type held by this error object.
    method
    error_tools::error::untyped::Error::chain
    &Error -> Chain
    An iterator of the chain of source errors contained by …
    method
    error_tools::error::untyped::Error::deref
    &Error -> &
    method
    error_tools::error::untyped::Error::drop
    &mut Error -> ()
    method
    error_tools::error::untyped::Error::as_ref
    &Error -> &ErrorTrait
    method
    error_tools::error::untyped::Error::backtrace
    &Error -> &Backtrace
    Get the backtrace for this Error.
    method
    error_tools::error::untyped::Error::root_cause
    &Error -> &ErrorTrait
    The lowest level cause of this error — this error’s …
    method
    error_tools::error::untyped::Error::deref_mut
    &mut Error -> &mut
    method
    error_tools::error::untyped::Error::context
    Error, C -> Error
    Wrap the error value with additional context.
    method
    error_tools::error::untyped::Error::fmt
    &Error, &mut Formatter -> Result<(), Error>
    method
    error_tools::error::untyped::Error::downcast
    Error -> Result<E, Error>
    Attempt to downcast the error object to a concrete type.
    method
    error_tools::error::untyped::Error::downcast_ref
    &Error -> Option<&E>
    Downcast this error object by reference.
    method
    error_tools::error::untyped::Error::downcast_mut
    &mut Error -> Option<&mut E>
    Downcast this error object by mutable reference.
    function
    error_tools::dependency::anyhow::Ok
    T -> Result<T, Error>
    Equivalent to Ok::<_, anyhow::Error>(value).
    method
    error_tools::error::untyped::Error::new
    E -> Error
    Create a new error object from any error type.
    method
    error_tools::error::untyped::Error::from
    E -> Error
    method
    error_tools::error::untyped::Error::msg
    M -> Error
    Create a new error object from a printable error message.
    trait method
    error_tools::error::untyped::Context::context
    Context, C -> Result<T, Error>
    Wrap the error value with additional context.
    trait method
    error_tools::error::untyped::Context::with_context
    Context, F -> Result<T, Error>
    Wrap the error value with additional context that is …
    method
    error_tools::error::untyped::Error::context
    Error, C -> Error
    Wrap the error value with additional context.
    method
    error_tools::error::untyped::Error::fmt
    &Error, &mut Formatter -> Result<(), Error>
    method
    error_tools::error::untyped::Error::downcast
    Error -> Result<E, Error>
    Attempt to downcast the error object to a concrete type.