Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

status: handle errors when writing output #1420

Merged
merged 6 commits into from
Dec 8, 2017

Conversation

JamieCrisman
Copy link
Contributor

What does this do / why do we need it?

Addresses #1410 which is adding error handling to status.go

What should your reviewer look out for in this PR?

Is this done correctly? The errors get passed back in the outputters, and then I try to handle them in runStatusAll when they're called.

Do you need help or clarification on anything?

Suggestions on tests or any general feedback. This my first PR to this. (I'm also in the vendor channel on the golang slack.)

Which issue(s) does this PR fix?

fixes #1410

Copy link
Collaborator

@darkowlzz darkowlzz 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.
Suggested a small change.
Also, please add this to the CHANGELOG.md file.

}

out.BasicFooter()
err = out.BasicFooter()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's call this error variable something else and have explicit not nil check and return for it. Because reassigning this variable here makes the previous values (line 577 & 579) never being used. And the following return seems to return errCount, which is not related to this outputter error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, I'll have it return separately rather than continuing to the end if it errors there. (as it is doing with BasicHeader(), BasicLine(), etc)

@darkowlzz darkowlzz changed the title [WIP] #1410 handle errors [WIP] status: handle errors when writing output Dec 1, 2017
Copy link
Collaborator

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

LGTM!
Sorry that it went unnoticed and I didn't suggest shortening the error block in the previous review.

CHANGELOG.md Outdated
@@ -20,6 +20,7 @@ IMPROVEMENTS:
* Make the gps package importable ([#1349](https://github.com/golang/dep/pull/1349)).
* Improve file copy performance by not forcing a file sync (PR #1408).
* Skip empty constraints during import ([#1414](https://github.com/golang/dep/pull/1349))
* Handle errors when writing output ([#1420](https://github.com/golang/dep/pull/1420))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems to be very general. Let's add "status output" to make it clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, good point!

err := out.BasicHeader()
if err != nil {
return false, 0, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be shortened to:

if err := out.BasicHeader(); err != nil {
    return false, 0, err
}

Sorry that I didn't notice and suggest this in the first review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oooh! That's nice and compact!

err := out.BasicLine(bsMap[string(proj.Ident().ProjectRoot)])
if err != nil {
return false, 0, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, can be shortened.

footerErr := out.BasicFooter()
if footerErr != nil {
return false, 0, footerErr
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, can be shortened.

err = out.MissingHeader()
if err != nil {
return false, 0, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, can be shortened.

}
err = out.MissingFooter()
if err != nil {
return false, 0, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, can be shortened.

@darkowlzz darkowlzz changed the title [WIP] status: handle errors when writing output status: handle errors when writing output Dec 6, 2017
@darkowlzz darkowlzz merged commit 3a59b68 into golang:master Dec 8, 2017
@darkowlzz
Copy link
Collaborator

Thanks for fixing this. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

status: handle errors when writing output
4 participants