Skip to content
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

Reduce use of unwrap in CLI #248

Open
fairingrey opened this issue Jan 6, 2022 · 1 comment
Open

Reduce use of unwrap in CLI #248

fairingrey opened this issue Jan 6, 2022 · 1 comment
Labels
developer experience Make nicer and easier to use for developers

Comments

@fairingrey
Copy link

There's a lot of unwrap use in https://github.com/spruceid/didkit/blob/c5c422f2469c2c5cc2f6e6d8746e95b552fce3ed/cli/src/main.rs that to an end user is probably not very useful to reveal the entire output of a panic to. Wrrors like file not found, malformed JSON, bad identifiers... where an error response is expected, but not where in particular the error happens in code.

Perhaps we could use https://docs.rs/anyhow and categorize errors into an enum CliError with more helpful error messages.

@clehner
Copy link
Contributor

clehner commented Mar 2, 2022

#255 is changing main to return a Result (anyhow::Result). unwrap() and expect(...) can then be changed to ? or .context(...)?. Error::source chains will appear in the stdout on error rather than the panic message.

@clehner clehner added the developer experience Make nicer and easier to use for developers label Apr 12, 2022
@clehner clehner changed the title Consider reducing use of unwrap in didkit CLI Reduce use of unwrap in CLI Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer experience Make nicer and easier to use for developers
Projects
None yet
Development

No branches or pull requests

2 participants