chore: use `http.StatusText`

Andrey Nering and Christian Rocha created

Co-authored-by: Christian Rocha <christian@rocha.is>

Change summary

errors.go | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)

Detailed changes

errors.go 🔗

@@ -3,6 +3,7 @@ package fantasy
 import (
 	"fmt"
 	"net/http"
+	"strings"
 
 	"github.com/charmbracelet/x/exp/slice"
 )
@@ -69,19 +70,7 @@ func (e RetryError) Unwrap() error {
 	return nil
 }
 
-var statusCodeToTitle = map[int]string{
-	http.StatusBadRequest:          "bad request",
-	http.StatusUnauthorized:        "authentication failed",
-	http.StatusForbidden:           "permission denied",
-	http.StatusNotFound:            "resource not found",
-	http.StatusTooManyRequests:     "rate limit exceeded",
-	http.StatusInternalServerError: "internal server error",
-	http.StatusBadGateway:          "bad gateway",
-	http.StatusServiceUnavailable:  "service unavailable",
-	http.StatusGatewayTimeout:      "gateway timeout",
-}
-
 // ErrorTitleForStatusCode returns a human-readable title for a given HTTP status code.
 func ErrorTitleForStatusCode(statusCode int) string {
-	return statusCodeToTitle[statusCode]
+	return strings.ToLower(http.StatusText(statusCode))
 }