pocket-core icon indicating copy to clipboard operation
pocket-core copied to clipboard

Add context relevant info to error messages in pocket-core/app/cmd/cli/

Open BenVanGithub opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. Error message return values are a bit cryptic and lack context which is obvious in the code, but invisible to the user.

Example 1.) command: pocket query node-params a returns: strconv.Atoi: parsing "a": invalid syntax

But should return something like: Invalid Height: "a" (followed by the more detailed error info)

Example 2.) command: pocket query node-params 100000000 returns: http://localhost:8082/v1/query/nodeparams the http status code was not okay: 400, and the status was: 400 Bad Request, with a response of {"code":400,"message":"failed to get Store: no data"}

But should return something like Invalid Height: "10000000" (followed by the more detailed error info)

I propose to go through each command in: pocket-core/app/cmd/cli/accounts.go pocket-core/app/cmd/cli/app.go pocket-core/app/cmd/cli/gov.go pocket-core/app/cmd/cli/node.go pocket-core/app/cmd/cli/query.go test each command against invalid arguments and augment the existing error returns with context info:

For example: this code inside pocket query balance: { var err error height, err = strconv.Atoi(args[1]) if err != nil { fmt.Println(err) return } } Would be modified to read: { var err error height, err = strconv.Atoi(args[1]) if err != nil { fmt.Println("Invalid Height: ",args[1],err) return } }

BenVanGithub avatar Oct 01 '20 17:10 BenVanGithub

Good call out @BenVanGithub would you mind tackling this issue?

andrewnguyen22 avatar Oct 02 '20 17:10 andrewnguyen22

I’d be happy to.  Please assign it to me.

BenVanGithub avatar Oct 02 '20 17:10 BenVanGithub