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

Standardizes errors in commands #359

Merged
merged 5 commits into from
Mar 25, 2019

Conversation

se7entyse7en
Copy link
Contributor

@se7entyse7en se7entyse7en commented Mar 20, 2019

Closes #291.
Closes #326.

@se7entyse7en se7entyse7en force-pushed the standardization-err-commands branch 2 times, most recently from c640a26 to 0e2d0c0 Compare March 21, 2019 08:25
@carlosms
Copy link
Contributor

Something failed in the integration tests

@@ -118,7 +118,7 @@ The remaining nodes are printed to standard output in JSON format.`,
Mode: mode,
})
if err != nil {
return fmt.Errorf("%T %v", err, err)
return fmt.Errorf("%T %v", err, humanize(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

fatal(err, "%T", err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed here.

@@ -43,7 +43,7 @@ var componentsListCmd = &cobra.Command{

cmps, err := components.List(context.Background(), allVersions)
if err != nil {
return fatal(err, "could not list images")
return wrapHumanizeErr(err, "could not list images")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit-pick: because we use this function a lot I would prefer shorter name. Options from the top of my head:

  • humanizef
  • wrapf
  • userErr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know maybe whumanizef? so that we have both humanize and whumanizef.

Copy link
Contributor

Choose a reason for hiding this comment

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

whumanizef

Please don't 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😂 I think that humanizef is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed here.

@se7entyse7en
Copy link
Contributor Author

Rebased and force pushed to include integration testing for OSX. Please take a look at last 3 commits, especially this.

// fatal converts known errors to human friendly message and logs it with fatal level
func fatal(err error, format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
// wrapHumanizeErr wraps and converts known errors to human friendly message
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong name after the function rename.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here.

…ands

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
… Run

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
@se7entyse7en se7entyse7en merged commit edc6e37 into src-d:master Mar 25, 2019
@se7entyse7en se7entyse7en deleted the standardization-err-commands branch March 25, 2019 12:35
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.

None yet

3 participants