mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
MAINTENANCE: Unknown rtypes should return errors, not a panic (#945)
* Eliminate panics related to unknown rtypes
This commit is contained in:
@ -10,12 +10,8 @@ import (
|
||||
// string (all the parameters of an MX, SRV, CAA, etc). Rather than have
|
||||
// each provider rewrite this code many times, here's a helper function to use.
|
||||
//
|
||||
// At this time, the idiom is to panic rather than continue with potentially
|
||||
// misunderstood data. We do this panic() at the provider level.
|
||||
// Therefore the typical calling sequence is:
|
||||
// if err := rc.PopulateFromString(rtype, value, origin); err != nil {
|
||||
// panic(fmt.Errorf("unparsable record received from provider: %w", err))
|
||||
// }
|
||||
// If this doesn't work for all rtypes, process the special cases then
|
||||
// call this for the remainder.
|
||||
func (r *RecordConfig) PopulateFromString(rtype, contents, origin string) error {
|
||||
if r.Type != "" && r.Type != rtype {
|
||||
panic(fmt.Errorf("assertion failed: rtype already set (%s) (%s)", rtype, r.Type))
|
||||
|
Reference in New Issue
Block a user