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