Crate error_tools

source ·
Expand description

§Module :: error_tools

experimentalrust-statusdocs.rsOpen 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::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

Modules§

  • Assertions.
  • Namespace with dependencies.
  • Alias for std::error::BasicError.
  • Exposed namespace of the module.
  • Exceptions handling mechanism for apps.
  • Exceptions handling mechanism for libs.
  • Shared with parent namespace of the module
  • Prelude to use essentials: use my_module::prelude::*.
  • Protected namespace of the module.

Macros§

  • Macro asserts that two expressions are identical to each other. Unlike std::assert_eq it is removed from a release build.
  • 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.
  • Macro asserts that two expressions are not identical to each other. Unlike std::assert_eq it is removed from a release build.
  • Macro asserts that two expressions are not identical to each other. Unlike std::assert_eq it is removed from a release build.
  • Macro to generate an error descriptor.
  • Macro to return an Err( error ) generating error descriptor.

Structs§

  • baic implementation of generic BasicError

Traits§

Type Aliases§