Skip to content

Commit

Permalink
chore: add owner to API error contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Sep 17, 2024
1 parent 0863c0e commit a739c33
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/provider/providers/porkbun/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (p *Provider) getRecords(ctx context.Context, client *http.Client, recordTy
const decodeBody = true
responseData, err := httpPost[jsonResponseData](ctx, client, url, postRecordsParams, decodeBody)
if err != nil {
return nil, fmt.Errorf("for record type %s: %w",
recordType, err)
return nil, fmt.Errorf("for record type %s and record owner %s: %w",
recordType, owner, err)
}

return responseData.Records, nil
Expand Down Expand Up @@ -73,8 +73,8 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client,
const decodeBody = false
_, err = httpPost[struct{}](ctx, client, url, postRecordsParams, decodeBody)
if err != nil {
return fmt.Errorf("for record type %s: %w",
recordType, err)
return fmt.Errorf("for record type %s and record owner %s: %w",
recordType, owner, err)
}

return nil
Expand Down Expand Up @@ -102,8 +102,8 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client,
const decodeBody = false
_, err = httpPost[struct{}](ctx, client, url, postRecordsParams, decodeBody)
if err != nil {
return fmt.Errorf("for record type %s and record id %s: %w",
recordType, recordID, err)
return fmt.Errorf("for record type %s, record owner %s and record id %s: %w",
recordType, owner, recordID, err)
}

return nil
Expand All @@ -127,7 +127,8 @@ func (p *Provider) deleteRecord(ctx context.Context, client *http.Client, record
const decodeBody = false
_, err = httpPost[struct{}](ctx, client, url, postRecordsParams, decodeBody)
if err != nil {
return err
return fmt.Errorf("for record type %s and record owner %s: %w",
recordType, owner, err)
}

return nil
Expand Down

0 comments on commit a739c33

Please sign in to comment.