Skip to content

Commit

Permalink
chore(porkbun): add context to top level errors
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Feb 9, 2024
1 parent cb3075e commit 1697697
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/provider/providers/porkbun/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,27 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
ipStr := ip.String()
recordIDs, err := p.getRecordIDs(ctx, client, recordType)
if err != nil {
return netip.Addr{}, err
return netip.Addr{}, fmt.Errorf("getting record IDs: %w", err)
}

if len(recordIDs) == 0 {
// ALIAS record needs to be deleted to allow creating an A record.
err = p.deleteALIASRecordIfNeeded(ctx, client)
if err != nil {
return netip.Addr{}, err
return netip.Addr{}, fmt.Errorf("deleting ALIAS record if needed: %w", err)
}

err = p.createRecord(ctx, client, recordType, ipStr)
if err != nil {
return netip.Addr{}, err
return netip.Addr{}, fmt.Errorf("creating record: %w", err)
}
return ip, nil
}

for _, recordID := range recordIDs {
err = p.updateRecord(ctx, client, recordType, ipStr, recordID)
if err != nil {
return netip.Addr{}, err
return netip.Addr{}, fmt.Errorf("updating record: %w", err)
}
}

Expand Down

0 comments on commit 1697697

Please sign in to comment.