aboutsummaryrefslogtreecommitdiff
path: root/mingling/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling/src')
-rw-r--r--mingling/src/example_docs.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index caa12ae..3171c22 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -1572,12 +1572,14 @@ pub mod example_lazy_resources {}
/// ```bash
/// cargo run --manifest-path examples/example-outside-type/Cargo.toml --quiet -- parse 42
/// cargo run --manifest-path examples/example-outside-type/Cargo.toml --quiet -- parse hello
+/// cargo run --manifest-path examples/example-outside-type/Cargo.toml --quiet -- error
/// ```
///
/// Output:
/// ```plaintext
/// Parsed number: 42
/// Parse error: invalid digit found in string
+/// IO_ERROR: Error
/// ```
///
/// Source code (./Cargo.toml)
@@ -1599,9 +1601,15 @@ pub mod example_lazy_resources {}
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::group, prelude::*};
-/// use std::num::ParseIntError;
+/// use std::{io::ErrorKind::Other, num::ParseIntError};
///
/// dispatcher!("parse");
+/// dispatcher!("error");
+///
+/// #[chain]
+/// fn handle_entry_error(_args: EntryError) -> Next {
+/// std::io::Error::new(Other, "Error").to_render()
+/// }
///
/// // --------- IMPORTANT ---------
/// // You can directly use the `group!` macro to define outside types as types
@@ -1610,6 +1618,10 @@ pub mod example_lazy_resources {}
/// // /
/// // vvvvvvvvvvvvv
/// group!(ParseIntError);
+/// group!(ErrorIo = std::io::Error);
+/// // ^^^^^^^^^^^^^^^^^^^^^^^^
+/// // \_____________ For types whose names may cause ambiguity,
+/// // you can use this syntax to create an alias simultaneously
/// // --------- IMPORTANT ---------
///
/// pack!(ParsedNumber = i32);
@@ -1644,9 +1656,18 @@ pub mod example_lazy_resources {}
/// r_println!("Parse error: {}", err);
/// }
///
+/// /// Renderer for IO errors — using `std::io::Error` registered as `ErrorIo`.
+/// // ________ Must use alias `ErrorIo` here, not bare `std::io::Error`
+/// // /
+/// #[renderer] // vvvvvvv
+/// fn render_error_io(err: ErrorIo) {
+/// r_println!("IO_ERROR: {}", err.to_string());
+/// }
+///
/// fn main() {
/// let mut program = ThisProgram::new();
/// program.with_dispatcher(CMDParse);
+/// program.with_dispatcher(CMDError);
/// program.exec_and_exit();
/// }
///