Skip to content

Commit

Permalink
providers/ultradns: handle record-not-found errors
Browse files Browse the repository at this point in the history
  • Loading branch information
josephholsten committed Oct 27, 2015
1 parent bfc112e commit e559738
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions builtin/providers/ultradns/resource_ultradns_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,23 @@ func resourceUltraDNSRecordRead(d *schema.ResourceData, meta interface{}) error

rrsets, _, err := client.RRSets.GetRRSets(d.Get("zone").(string), d.Get("name").(string), d.Get("type").(string))
if err != nil {
return fmt.Errorf("Couldn't find UltraDNS RRSet: %s", err)
uderr, ok := err.(*udnssdk.ErrorResponseList)
if ok {
for _, r := range uderr.Responses {
// 70002 means Records Not Found
if r.ErrorCode == 70002 {
d.SetId("")
return nil
} else {
return fmt.Errorf("Couldn't find UltraDNS RRSet: %s", err)
}
}
} else {
return fmt.Errorf("Couldn't find UltraDNS RRSet: %s", err)
}
}
rec := rrsets[0]
err := d.Set("rdata", rec.RData)
err = d.Set("rdata", rec.RData)
if err != nil {
return fmt.Errorf("[DEBUG] Error setting records: %#v", err)
}
Expand Down

0 comments on commit e559738

Please sign in to comment.