macro_rules! other_err {
( $context:expr, source: $source:expr $(,)? ) => { ... };
( $context:expr, $description:expr $(,)? ) => { ... };
( source: $source:expr $(,)? ) => { ... };
( $description:expr $(,)? ) => { ... };
}
Expand description
Creates a generic “other” error with optional context and source information.
This macro generates a generic error that can include a description, context, and an optional source error. It’s useful for creating custom errors or wrapping other errors with additional context.
§Arguments
description
- A description of the error (optional)context
- The context in which the error occurred (optional)source
- The source error, if this error is wrapping another (optional)
§Examples
use ironrdp_core::other_err;
// With description and source
let source_err = std::io::Error::new(std::io::ErrorKind::Other, "Source error");
let err = other_err!("Something went wrong", source: source_err);
// With context and description
let err = other_err!("parsing input", "Unexpected end of file");
// With only description
let err = other_err!("Operation failed");
// With only source
let err = other_err!(source: std::io::Error::new(std::io::ErrorKind::Other, "IO error"));
§Note
If the context is not provided, it will use the current function name.