aboutsummaryrefslogtreecommitdiff
path: root/examples/example-error-handling/src
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-31 02:42:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-31 17:19:20 +0800
commit2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 (patch)
treef10b89007fc67ca1a948f34abe6869b49296b932 /examples/example-error-handling/src
parent3aa409a55e4f2f0ab41b0949cc06eb13c2da4a43 (diff)
Enhance code quality across the entire codebase
Diffstat (limited to 'examples/example-error-handling/src')
-rw-r--r--examples/example-error-handling/src/main.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/example-error-handling/src/main.rs b/examples/example-error-handling/src/main.rs
index d4d073e..ae79b97 100644
--- a/examples/example-error-handling/src/main.rs
+++ b/examples/example-error-handling/src/main.rs
@@ -59,29 +59,34 @@ fn handle_hello(args: EntryHello) -> Next {
ResultName::new(name).to_render()
}
+/// Renders a successful greeting with the given name.
#[renderer]
fn render_result_name(name: ResultName) {
r_println!("Hello, {}", *name);
}
+/// Renders the error when no name is provided.
#[renderer]
fn render_error_no_name_provided(_: ErrorNoNameProvided) {
// Prompt when no name is provided
r_println!("No name provided");
}
+/// Renders the error when the name is already taken.
#[renderer]
fn render_error_name_not_available(_: ErrorNameNotAvailable) {
// Prompt when name is already taken
r_println!("Name not available");
}
+/// Renders the error when the name exceeds the maximum length.
#[renderer]
fn render_error_name_too_long(len: ErrorNameTooLong) {
// Prompt when name is too long, showing actual length
r_println!("Name too long: {} > 10", *len);
}
+/// Renders the error when the dispatcher (subcommand) is not found.
#[renderer]
fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) {
// Prompt when command is not found, showing the input command