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

feat: improve errors in the CLI #682

Merged
merged 13 commits into from
Jan 24, 2025
Merged

Conversation

SantiagoPittella
Copy link
Collaborator

@SantiagoPittella SantiagoPittella commented Jan 21, 2025

closes #369
Current state of the errors:

image

@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-cli-error-type branch 3 times, most recently from be14a21 to 5c8c5b7 Compare January 21, 2025 21:48
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! I haven't finished looking at all the files yet but leaving some comments for now

bin/miden-cli/Cargo.toml Outdated Show resolved Hide resolved
bin/miden-cli/src/commands/init.rs Outdated Show resolved Hide resolved
bin/miden-cli/src/commands/account.rs Outdated Show resolved Hide resolved
bin/miden-cli/src/errors.rs Outdated Show resolved Hide resolved
bin/miden-cli/src/commands/export.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving some comments, the only big one being related to not losing source error information on places where we do err.to_string(). This might have some more information.
Other than that, I think that this is a great improvement over the current CLI errors and so we could merge this after having revised that aspect.

bin/miden-cli/src/errors.rs Outdated Show resolved Hide resolved
bin/miden-cli/src/errors.rs Outdated Show resolved Hide resolved
bin/miden-cli/src/errors.rs Show resolved Hide resolved
bin/miden-cli/src/errors.rs Outdated Show resolved Hide resolved
bin/miden-cli/src/errors.rs Outdated Show resolved Hide resolved
@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-cli-error-type branch 3 times, most recently from a1e39d8 to 8bfbd65 Compare January 23, 2025 18:40
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left just one comment about refactoring the display implementations for errors with source


#[derive(Debug, Diagnostic, Error)]
pub enum CliError {
#[error("account error: {1} with error {0}")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here (and in the other similar variants), showing the source error (ie, displaying {1}) is redundant because error reporters will automatically report the source errors as part of the output. We could test this by inducing an error (randomly picked one):

Error: cli::account_error

  × account error: error executing command with error storage slot at index 5 is not of type
  │ map
  ╰─▶ storage slot at index 5 is not of type map

So I think we could just display the String as the top-level reason why the command failed, and then the source error.

@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-cli-error-type branch from 528edbc to f271502 Compare January 23, 2025 20:00
Cargo.toml Show resolved Hide resolved
@igamigo igamigo merged commit c93b690 into next Jan 24, 2025
15 checks passed
@igamigo igamigo deleted the santiagopittella-cli-error-type branch January 24, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants