mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
wrap more errors
This commit is contained in:
@ -139,11 +139,11 @@ func GetZone(args GetZoneArgs) error {
|
|||||||
// Read it in:
|
// Read it in:
|
||||||
providerConfigs, err = config.LoadProviderConfigs(args.CredsFile)
|
providerConfigs, err = config.LoadProviderConfigs(args.CredsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed GetZone lpc(%q): %w", args.CredsFile, err)
|
||||||
}
|
}
|
||||||
provider, err := providers.CreateDNSProvider(args.ProviderName, providerConfigs[args.CredName], nil)
|
provider, err := providers.CreateDNSProvider(args.ProviderName, providerConfigs[args.CredName], nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed GetZone cdp: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// decide which zones we need to convert
|
// decide which zones we need to convert
|
||||||
@ -155,7 +155,7 @@ func GetZone(args GetZoneArgs) error {
|
|||||||
}
|
}
|
||||||
zones, err = lister.ListZones()
|
zones, err = lister.ListZones()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed GetZone LZ: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ func GetZone(args GetZoneArgs) error {
|
|||||||
w, err = os.Create(args.OutputFile)
|
w, err = os.Create(args.OutputFile)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed GetZone Create(%q): %w", args.OutputFile, err)
|
||||||
}
|
}
|
||||||
defer w.Close()
|
defer w.Close()
|
||||||
|
|
||||||
@ -181,11 +181,12 @@ func GetZone(args GetZoneArgs) error {
|
|||||||
for i, zone := range zones {
|
for i, zone := range zones {
|
||||||
recs, err := provider.GetZoneRecords(zone)
|
recs, err := provider.GetZoneRecords(zone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed GetZone gzr: %w", err)
|
||||||
}
|
}
|
||||||
zoneRecs[i] = recs
|
zoneRecs[i] = recs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write the heading:
|
// Write the heading:
|
||||||
|
|
||||||
if args.OutputFormat == "js" || args.OutputFormat == "djs" {
|
if args.OutputFormat == "js" || args.OutputFormat == "djs" {
|
||||||
|
@ -35,7 +35,7 @@ func testFormat(t *testing.T, domain, format string) {
|
|||||||
|
|
||||||
outfile, err := ioutil.TempFile("", outputFiletmpl)
|
outfile, err := ioutil.TempFile("", outputFiletmpl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(fmt.Errorf("gz can't TempFile %q: %w", outputFiletmpl, err))
|
||||||
}
|
}
|
||||||
defer os.Remove(outfile.Name())
|
defer os.Remove(outfile.Name())
|
||||||
|
|
||||||
@ -52,19 +52,19 @@ func testFormat(t *testing.T, domain, format string) {
|
|||||||
// Read the zonefile and convert
|
// Read the zonefile and convert
|
||||||
err = GetZone(gzargs)
|
err = GetZone(gzargs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(fmt.Errorf("can't GetZone: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the actual result:
|
// Read the actual result:
|
||||||
got, err := ioutil.ReadFile(outfile.Name())
|
got, err := ioutil.ReadFile(outfile.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(fmt.Errorf("can't read actuals %q: %w", outfile.Name(), err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the expected result
|
// Read the expected result
|
||||||
want, err := ioutil.ReadFile(expectedFilename)
|
want, err := ioutil.ReadFile(expectedFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(fmt.Errorf("can't read expected %q: %w", outfile.Name(), err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Update got -> want
|
// // Update got -> want
|
||||||
@ -76,5 +76,4 @@ func testFormat(t *testing.T, domain, format string) {
|
|||||||
if w, g := string(want), string(got); w != g {
|
if w, g := string(want), string(got); w != g {
|
||||||
t.Errorf("testFormat mismatch (-got +want):\n%s", diff.LineDiff(g, w))
|
t.Errorf("testFormat mismatch (-got +want):\n%s", diff.LineDiff(g, w))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user