Skip to content

Commit

Permalink
fix(setter): print out better error messages (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia authored Aug 6, 2022
1 parent 889a7c2 commit 68007f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions internal/setter/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *setter) Set(ctx context.Context, ppfmt pp.PP, domain api.Domain, ipnet

rs, ok := s.Handle.ListRecords(ctx, ppfmt, domain, ipnet)
if !ok {
ppfmt.Errorf(pp.EmojiError, "Failed to (fully) update %s records of %q", recordType, domainDescription)
ppfmt.Errorf(pp.EmojiError, "Failed to retrieve the current %s records of %q", recordType, domainDescription)
return false
}

Expand Down Expand Up @@ -148,7 +148,9 @@ func (s *setter) Set(ctx context.Context, ppfmt pp.PP, domain api.Domain, ipnet

// It is okay to have duplicates, but it is not okay to have stale records.
if !uptodate || numUndeletedUnmatched > 0 {
ppfmt.Errorf(pp.EmojiError, "Failed to (fully) update %s records of %q", recordType, domainDescription)
ppfmt.Errorf(pp.EmojiError,
"Failed to complete updating of %s records of %q; records might be inconsistent",
recordType, domainDescription)
return false
}

Expand Down
6 changes: 3 additions & 3 deletions internal/setter/setter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func TestSet(t *testing.T) {
gomock.InOrder(
m.EXPECT().Noticef(pp.EmojiDelRecord, "Deleted a stale %s record of %q (ID: %s)", "AAAA", "sub.test.org", record2),
m.EXPECT().Noticef(pp.EmojiAddRecord, "Added a new %s record of %q (ID: %s)", "AAAA", "sub.test.org", record3),
m.EXPECT().Errorf(pp.EmojiError, "Failed to (fully) update %s records of %q", "AAAA", "sub.test.org"),
m.EXPECT().Errorf(pp.EmojiError, "Failed to complete updating of %s records of %q; records might be inconsistent", "AAAA", "sub.test.org"), //nolint:lll
)
},
func(ctx context.Context, ppfmt pp.PP, m *mocks.MockHandle) {
Expand All @@ -252,7 +252,7 @@ func TestSet(t *testing.T) {
gomock.InOrder(
m.EXPECT().Noticef(pp.EmojiDelRecord, "Deleted a stale %s record of %q (ID: %s)", "AAAA", "sub.test.org", record1),
m.EXPECT().Noticef(pp.EmojiDelRecord, "Deleted a stale %s record of %q (ID: %s)", "AAAA", "sub.test.org", record2),
m.EXPECT().Errorf(pp.EmojiError, "Failed to (fully) update %s records of %q", "AAAA", "sub.test.org"),
m.EXPECT().Errorf(pp.EmojiError, "Failed to complete updating of %s records of %q; records might be inconsistent", "AAAA", "sub.test.org"), //nolint:lll
)
},
func(ctx context.Context, ppfmt pp.PP, m *mocks.MockHandle) {
Expand All @@ -270,7 +270,7 @@ func TestSet(t *testing.T) {
ip1,
false,
func(m *mocks.MockPP) {
m.EXPECT().Errorf(pp.EmojiError, "Failed to (fully) update %s records of %q", "AAAA", "sub.test.org")
m.EXPECT().Errorf(pp.EmojiError, "Failed to retrieve the current %s records of %q", "AAAA", "sub.test.org")
},
func(ctx context.Context, ppfmt pp.PP, m *mocks.MockHandle) {
m.EXPECT().ListRecords(ctx, ppfmt, domain, ipNetwork).Return(nil, false)
Expand Down

0 comments on commit 68007f8

Please sign in to comment.