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

cli: errors are displayed twice #300

Closed
btc opened this issue Nov 12, 2014 · 8 comments
Closed

cli: errors are displayed twice #300

btc opened this issue Nov 12, 2014 · 8 comments

Comments

@btc
Copy link
Contributor

btc commented Nov 12, 2014

see ipfs2 add at fd9ffb5
pasted_image_11_11_14__7_43_pm

@btc btc added this to the merge commands milestone Nov 12, 2014
@whyrusleeping
Copy link
Member

@maybebtc which fish prompt/theme do you use?

@btc
Copy link
Contributor Author

btc commented Nov 12, 2014

@whyrusleeping
Copy link
Member

Ah, nice! I approve! I just use a simple robbyrussel git info prompt.

@btc
Copy link
Contributor Author

btc commented Nov 12, 2014

@mappum

In ipfs2 main, when the program decides what to write out to the user (based on result of command execution), what is the significance of commands.Response.Error.Code?

What I am reading is...

a) If the code is not ErrClient, return the error and only the error.

b) If the code is ErrClient, print help text.

However, having read through the source, I do not feel confident in my ability to predict how the framework will classify the wide range of errors into these two classes. Is there a principle behind the distinction?

The reason this is important is that the code appears to dictate the result displayed to the user:

This seems to be an ErrNormal:

go-ipfs (cmd-ref-part2) λ. ipfs2 diag net
ERROR: This command must be run in online mode. Try running 'ipfs daemon' first.

This is an ErrClient:

go-ipfs (cmd-ref-part2) λ. ipfs2 diag                                                                                
ERROR: This command can't be called directly. Try one of its subcommands.

USAGE:

    ipfs diag - Generates diagnostic reports

Use 'ipfs diag --help' for more information about this command.

@mappum can you help me understand?

@mappum
Copy link
Contributor

mappum commented Nov 12, 2014

@maybebtc The essential difference between the two is that ErrClient errors are a fault of the caller using the tool incorrectly (akin to HTTP 4xx errors), and ErrNormal is for any other errors (typically ones caused by the system, like HTTP 5xx).

For example, not providing a required argument would be an ErrClient, and would mean we should instruct the user on how to properly form a request (which is why we print the help text).

An error like timing out when trying to resolve an IPNS name would be an ErrNormal, as it's not a direct fault of the user, and help text wouldn't really be relevant to their problem.

@jbenet
Copy link
Member

jbenet commented Nov 12, 2014

@mappum yeah there is a semantic distinction, but how are they distinguished in the code? who decides what the error is? Does each function -- on finding an error -- get to set wheter it's an ErrClient or ErrNormal? i think the main concern is about how obvious it is to a user.

@btc
Copy link
Contributor Author

btc commented Nov 13, 2014

@jbenet thank you for getting to the kernel. How are they distinguished in code? What components are responsible for classification?

@jbenet
Copy link
Member

jbenet commented Nov 13, 2014

I fixed this Issue. @maybebtc can you verify and close?

@btc btc closed this as completed Nov 13, 2014
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

No branches or pull requests

4 participants