Crate proc_nuhound

Crate proc_nuhound 

Source
Expand description

A Rust library of proc-macros for nuhound error tracing

Rust programmers often find the question mark operator invaluable in extracting values from Result and Option and immediately returning to the calling context in the case of an Err or None. This library provides a trio of proc-macros that simplify the use of the nuhound type in error tracing.

With the disclose feature enabled, the error messages contain the line number and column number of the source file that originated the error. This functionality is provided by the convert!, examine! and custom! macros. These macros are designed to help simplify error handling in a concise and consistent Rust style in line with the nuhound paradigm.

These macros require nuhound v0.2 or later.

For a fuller explanation of usage please refer to the nuhound crate v0.2 onwards.

Macrosยง

convert
A macro to prepare a Nuhound type error from any error type that implements the Error trait. This also includes Nuhound errors. Resultant errors may be handled using the ? operator or by simply returning it to the calling context as a Result::Err directly.
custom
A macro to prepare a Nuhound type error. Whilst the convert and examine macros are designed to respond to previously handled errors, the custom macro will always generate a Nuhound error without any pre-conditions. Resultant errors may be handled using the ? operator or by simply returning it to the calling context as a Result::Err directly. Normal usage of this macro would suggest using it inside a condition block and returning the error to the calling context with return custom!("My error message");.
examine
A macro to prepare a Nuhound type error from previously handled Nuhound error(s). Whilst the convert macro is completely error type agnostic provided the error handler implements the Error trait, the examine macro requires much less binary code to implement and hence is more efficient. Resultant errors are handled using the ? operator by simply returning it to the calling context as a Result::Err directly.