Skip to content

Commit a54f50d

Browse files
chore: use http.StatusText
Co-authored-by: Christian Rocha <[email protected]>
1 parent 9e77443 commit a54f50d

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

errors.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package fantasy
33
import (
44
"fmt"
55
"net/http"
6+
"strings"
67

78
"github.com/charmbracelet/x/exp/slice"
89
)
@@ -69,19 +70,7 @@ func (e RetryError) Unwrap() error {
6970
return nil
7071
}
7172

72-
var statusCodeToTitle = map[int]string{
73-
http.StatusBadRequest: "bad request",
74-
http.StatusUnauthorized: "authentication failed",
75-
http.StatusForbidden: "permission denied",
76-
http.StatusNotFound: "resource not found",
77-
http.StatusTooManyRequests: "rate limit exceeded",
78-
http.StatusInternalServerError: "internal server error",
79-
http.StatusBadGateway: "bad gateway",
80-
http.StatusServiceUnavailable: "service unavailable",
81-
http.StatusGatewayTimeout: "gateway timeout",
82-
}
83-
8473
// ErrorTitleForStatusCode returns a human-readable title for a given HTTP status code.
8574
func ErrorTitleForStatusCode(statusCode int) string {
86-
return statusCodeToTitle[statusCode]
75+
return strings.ToLower(http.StatusText(statusCode))
8776
}

0 commit comments

Comments
 (0)