-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better panic
handling
#9
Comments
Hi @mattgodbolt , I hacked together a solution with autocomplete. What do you think of the following output? chris@christophs-air rizzy % cargo run -- -z America/Chi
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/rizzy -z America/Chi`
Error:
0: Unknown timezone 'America/Chi', did you mean: ["America/Chihuahua", "America/Chicago"]
Location:
src/main.rs:103
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
|
Thanks @siedentop ! I was wondering about maybe not panic-ing at all in these cases and handling it more user-friendlyly. This is a huge improvement of course, but as a user of a tool, I probably never want to see anything specific to the language a command-line tool was written in if I mistyped an option :-) I love the autocomplete thing, and I guess I would imagine an ideal output is:
The rest is visual noise to the user (though handy if you are a developer). My sort of mental model is if you typed a bad command-line parameter to
and not something like
(etc!) I have this beef with plenty of Python tools that expose their innards to unsuspecting users if the user makes a mistake :) |
Yes, totally! The answer to that is to use I'll add a patch in a day or so. |
I updated this. But the upstream library still has not had a response to my request to make the list of timezone names readable from the library. |
UPDATE: It looks like the upstream library (chrono-tz) is willing to merge my patch. |
I'm not sure what the rust-y way to do this is but when I typo a timezone, this seems pretty nasty:
The text was updated successfully, but these errors were encountered: