Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Lucas authored and iknite committed Feb 19, 2019
1 parent 2618bf4 commit b087eb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion balloon/balloon.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (b Balloon) QueryDigestMembership(keyDigest hashing.Digest, version uint64)
historyProof, historyErr = b.historyTree.ProveMembership(proof.ActualVersion, proof.QueryVersion)
}()
} else {
return nil, fmt.Errorf("query version %d is not on history tree which version is %d", proof.QueryVersion, proof.ActualVersion)
return nil, fmt.Errorf("Query version %d is not on history tree which version is %d", proof.QueryVersion, proof.ActualVersion)
}

hyperProof, hyperErr = b.hyperTree.QueryMembership(leaf.Key, leaf.Value)
Expand Down
18 changes: 9 additions & 9 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ func (c HTTPClient) doReq(method, path string, data []byte) ([]byte, error) {
bodyBytes, _ := ioutil.ReadAll(resp.Body)

if resp.StatusCode >= 500 {
return nil, fmt.Errorf("Unexpected server error")
return nil, fmt.Errorf("Server error: %v", string(bodyBytes))
}

if resp.StatusCode >= 400 && resp.StatusCode < 500 {
return nil, fmt.Errorf("Invalid request")
return nil, fmt.Errorf("Invalid request %v", string(bodyBytes))
}

return bodyBytes, nil
Expand Down Expand Up @@ -163,7 +163,7 @@ func (c HTTPClient) Membership(key []byte, version uint64) (*protocol.Membership
}

var proof *protocol.MembershipResult
json.Unmarshal(body, &proof)
_ = json.Unmarshal(body, &proof)

return proof, nil

Expand All @@ -173,8 +173,8 @@ func (c HTTPClient) Membership(key []byte, version uint64) (*protocol.Membership
func (c HTTPClient) MembershipDigest(keyDigest hashing.Digest, version uint64) (*protocol.MembershipResult, error) {

query, _ := json.Marshal(&protocol.MembershipDigest{
keyDigest,
version,
KeyDigest: keyDigest,
Version: version,
})

body, err := c.doReq("POST", "/proofs/digest-membership", query)
Expand All @@ -183,7 +183,7 @@ func (c HTTPClient) MembershipDigest(keyDigest hashing.Digest, version uint64) (
}

var proof *protocol.MembershipResult
json.Unmarshal(body, &proof)
_ = json.Unmarshal(body, &proof)

return proof, nil

Expand All @@ -193,8 +193,8 @@ func (c HTTPClient) MembershipDigest(keyDigest hashing.Digest, version uint64) (
func (c HTTPClient) Incremental(start, end uint64) (*protocol.IncrementalResponse, error) {

query, _ := json.Marshal(&protocol.IncrementalRequest{
start,
end,
Start: start,
End: end,
})

body, err := c.doReq("POST", "/proofs/incremental", query)
Expand All @@ -203,7 +203,7 @@ func (c HTTPClient) Incremental(start, end uint64) (*protocol.IncrementalRespons
}

var response *protocol.IncrementalResponse
json.Unmarshal(body, &response)
_ = json.Unmarshal(body, &response)

return response, nil
}
Expand Down

0 comments on commit b087eb4

Please sign in to comment.