Skip to content

Commit

Permalink
terminal error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sheidkamp committed Aug 7, 2023
1 parent 40203bf commit 84525cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/reconcile/reconcile.go
Expand Up @@ -112,11 +112,15 @@ type terminalError struct {
err error
}

// This function will return nil if te.err is nil.
func (te *terminalError) Unwrap() error {
return te.err
}

func (te *terminalError) Error() string {
if te.err == nil {
return "nil terminal error"
}
return "terminal error: " + te.err.Error()
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/reconcile/reconcile_test.go
Expand Up @@ -96,5 +96,10 @@ var _ = Describe("reconcile", func() {

Expect(apierrors.IsGone(terminalError)).To(BeTrue())
})

It("should handle nil terminal errors properly", func() {
err := reconcile.TerminalError(nil)
Expect(err.Error()).To(Equal("nil terminal error"))
})
})
})

0 comments on commit 84525cc

Please sign in to comment.