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

Improve error message : add request ID #615

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions ovh/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,13 @@ func ConditionalAttributeBool(buff *bytes.Buffer, name string, val *bool) {
// CheckDeleted checks the error to see if it's a 404 (Not Found) and, if so,
// sets the resource ID to the empty string instead of throwing an error.
func CheckDeleted(d *schema.ResourceData, err error, endpoint string) error {
if errOvh, ok := err.(*ovh.APIError); ok && errOvh.Code == 404 {
errOvh, ok := err.(*ovh.APIError);
if ok && errOvh.Code == 404 {
d.SetId("")
return nil
}

return fmt.Errorf("calling %s:\n\t %s", endpoint, err.Error())
return fmt.Errorf("calling %s:\n\t %s Query ID : %s", endpoint, err.Error(), errOvh.QueryID)
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use errOvh.QueryID only if we're sure that ok is true, something like:

var queryID string
if ok {
  queryID = errOvh.QueryID
}

}

func StringsFromSchema(d *schema.ResourceData, id string) ([]string, error) {
Expand Down