Documentation
¶
Overview ¶
Package errorutil provides shared helpers for classifying and inspecting errors returned by the GitHub API and gh CLI.
Index ¶
- func IsAlreadyMergedError(err error) bool
- func IsAuthError(output string) bool
- func IsForbiddenError(err error) bool
- func IsGoneError(err error) bool
- func IsInsufficientScopesError(err error) bool
- func IsNotFoundError(err error) bool
- func IsNotFoundOutput(output string) bool
- func IsRateLimitError(output string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyMergedError ¶ added in v0.87.3
IsAlreadyMergedError reports whether err indicates that a `gh pr merge` operation failed because the pull request was already merged. The gh CLI only surfaces this state via error text: either the phrase "already merged" (matched case-insensitively) or the uppercase GraphQL "MERGED" state literal (matched case-sensitively so that ordinary wording such as "could not be merged" or "not merged" is not misclassified as success). It returns false when err is nil.
Exception: `gh pr merge` exposes no structured state for this condition, so classification is necessarily a substring match. The match lives here rather than at call sites so the fragile literals are documented, tested, and updated in one place.
func IsAuthError ¶ added in v0.87.1
IsAuthError reports whether output indicates an authentication or authorization issue from the GitHub API or gh CLI.
func IsForbiddenError ¶ added in v0.74.5
IsForbiddenError reports whether err represents an HTTP 403 / "forbidden" response. It returns false when err is nil. The check is case-insensitive and only matches HTTP-style 403 patterns such as "HTTP 403" or "403 Forbidden", which avoids misclassifying unrelated errors like "forbidden character".
func IsGoneError ¶ added in v0.74.5
IsGoneError reports whether err represents an HTTP 410 / "gone" response. It returns false when err is nil. The check is case-insensitive and only matches HTTP-style 410 patterns such as "HTTP 410" or "410 Gone", which avoids misclassifying unrelated errors like "connection has gone away".
func IsInsufficientScopesError ¶ added in v0.87.3
IsInsufficientScopesError reports whether err indicates that a GitHub GraphQL API request was rejected because the authenticated token is missing required OAuth/PAT scopes. The gh CLI and GitHub GraphQL API surface this as the literal "INSUFFICIENT_SCOPES" error type. It returns false when err is nil.
Exception: the gh CLI returns this condition only as error text, with no machine-readable type or status code, so classification is necessarily a substring match. The match lives here rather than at call sites so the fragile literal is documented, tested, and updated in one place.
func IsNotFoundError ¶
IsNotFoundError reports whether err represents an HTTP 404 / "not found" response. It returns false when err is nil. The check is case-insensitive and matches both the numeric literal "404" and the phrase "not found", which covers all known forms returned by the GitHub API, the gh CLI, and the go-gh library.
func IsNotFoundOutput ¶ added in v0.86.3
IsNotFoundOutput reports whether output represents an HTTP 404 / "not found" response. The check is case-insensitive and matches both the numeric literal "404" and the phrase "not found".
func IsRateLimitError ¶ added in v0.87.1
IsRateLimitError reports whether output indicates a GitHub API rate-limit error. The check is case-insensitive and matches known API phrases.
Types ¶
This section is empty.