cleanup: rename errorPair to pairError

to fix the errname check renaming the
struct.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2022-01-21 15:12:35 +05:30 committed by mergify[bot]
parent 4938fc2ff4
commit 9c841c83d4

View File

@ -39,27 +39,27 @@ var (
ErrMissingConfigForMonitor = errors.New("missing configuration of cluster ID for monitor") ErrMissingConfigForMonitor = errors.New("missing configuration of cluster ID for monitor")
) )
type errorPair struct { type pairError struct {
first error first error
second error second error
} }
func (e errorPair) Error() string { func (e pairError) Error() string {
return fmt.Sprintf("%v: %v", e.first, e.second) return fmt.Sprintf("%v: %v", e.first, e.second)
} }
// Is checks if target error is wrapped in the first error. // Is checks if target error is wrapped in the first error.
func (e errorPair) Is(target error) bool { func (e pairError) Is(target error) bool {
return errors.Is(e.first, target) return errors.Is(e.first, target)
} }
// Unwrap returns the second error. // Unwrap returns the second error.
func (e errorPair) Unwrap() error { func (e pairError) Unwrap() error {
return e.second return e.second
} }
// JoinErrors combines two errors. Of the returned error, Is() follows the first // JoinErrors combines two errors. Of the returned error, Is() follows the first
// branch, Unwrap() follows the second branch. // branch, Unwrap() follows the second branch.
func JoinErrors(e1, e2 error) error { func JoinErrors(e1, e2 error) error {
return errorPair{e1, e2} return pairError{e1, e2}
} }