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

Check errIn, not err #754

Closed
wants to merge 1 commit into from
Closed

Check errIn, not err #754

wants to merge 1 commit into from

Conversation

md2perpe
Copy link
Contributor

@md2perpe md2perpe commented Sep 4, 2017

It really looks like errIn should be checked, not err.

It really looks like `errIn` should be checked, not `err`.
Copy link
Member

@marstr marstr left a comment

Choose a reason for hiding this comment

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

Thanks for catching this masked error. Us Azure SDK for Go folks may need to chat about how we want to fix this, though.

@@ -437,12 +437,12 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader
// response contains storage service error object, unmarshal
if resp.Header.Get("Content-Type") == "application/xml" {
errIn := serviceErrFromXML(respBody, &storageErr)
if err != nil { // error unmarshaling the error response
if errIn != nil { // error unmarshaling the error response
err = errIn
Copy link
Member

Choose a reason for hiding this comment

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

Good catch seeing the masked error. However, I'm not sure this fix goes far enough to fix it. As it is in this PR, errIn gets blown away anyway.

@mcardosos, what are your thoughts? Maybe we should be extending the AzureStorageServiceError to include an inner error in the case of marshaling trouble?

Copy link
Contributor

Choose a reason for hiding this comment

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

Take a look into the serviceErrFromXML and serviceErrFromJSON funcs. They both include the unmarshal errors in AzureStorageServiceError.Message. I actually think we could get rid of if err != nil. Code would look like this...

if resp.Header.Get("Content-Type") == "application/xml" {
	serviceErrFromXML(respBody, &storageErr)
} else {
	serviceErrFromJSON(respBody, &storageErr)
}

Copy link
Member

Choose a reason for hiding this comment

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

Talking IRL with @mcardosos, she showed me that we do actually percolate up the un-marshaling error already. I like the blurb that she has above, let's do that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marstr I noticed afterwards that the error is blown away, but thought that you need to take a look at the whole code block. As I did this at work I didn't want to put too much time into it.

@tombuildsstuff
Copy link
Contributor

👋🏻 out of interest does this fix #748?

@mcardosos
Copy link
Contributor

@tombuildsstuff These issues are not related :(

@mcardosos
Copy link
Contributor

@md2perpe ping

@md2perpe
Copy link
Contributor Author

@mcardosos pong

@Azure Azure deleted a comment from msftclas Sep 26, 2017
@marstr
Copy link
Member

marstr commented Oct 25, 2017

It seems like this PR has gone stale. I'm going to close it out.

@marstr marstr closed this Oct 25, 2017
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.

6 participants