chore: remove `GetErrorMessage` helper

Andrey Nering created

Change summary

errors.go | 8 --------
retry.go  | 6 +++---
2 files changed, 3 insertions(+), 11 deletions(-)

Detailed changes

errors.go 🔗

@@ -133,11 +133,3 @@ func NewUnsupportedFunctionalityError(functionality, message string) *Unsupporte
 		Functionality: functionality,
 	}
 }
-
-// GetErrorMessage extracts a message from an error.
-func GetErrorMessage(err error) string {
-	if err == nil {
-		return "unknown error"
-	}
-	return err.Error()
-}

retry.go 🔗

@@ -129,13 +129,13 @@ func retryWithExponentialBackoff[T any](ctx context.Context, fn RetryFn[T], opti
 		return zero, err // don't wrap the error when retries are disabled
 	}
 
-	errorMessage := GetErrorMessage(err)
+	errorMessage := err.Error()
 	newErrors := append(allErrors, err)
 	tryNumber := len(newErrors)
 
 	if tryNumber > options.MaxRetries {
 		return zero, NewRetryError(
-			fmt.Sprintf("Failed after %d attempts. Last error: %s", tryNumber, errorMessage),
+			fmt.Sprintf("Failed after %d attempts. Last error: %v", tryNumber, errorMessage),
 			RetryReasonMaxRetriesExceeded,
 			newErrors,
 		)
@@ -166,7 +166,7 @@ func retryWithExponentialBackoff[T any](ctx context.Context, fn RetryFn[T], opti
 	}
 
 	return zero, NewRetryError(
-		fmt.Sprintf("Failed after %d attempts with non-retryable error: '%s'", tryNumber, errorMessage),
+		fmt.Sprintf("Failed after %d attempts with non-retryable error: %v", tryNumber, errorMessage),
 		RetryReasonErrorNotRetryable,
 		newErrors,
 	)