errorutil

package
v0.75.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 1 Imported by: 0

README

errorutil Package

The errorutil package provides shared helpers for classifying and inspecting errors returned by the GitHub API and gh CLI.

Overview

This package currently exposes focused helpers for identifying common error categories used across pkg/cli and pkg/parser, including "not found" (404), "forbidden" (403), and "gone" (410) responses.

Public API

Functions
Function Signature Description
IsNotFoundError func(err error) bool Returns true when err indicates a "not found" condition by matching case-insensitive 404 or not found text; returns false for nil and non-matching errors
IsForbiddenError func(err error) bool Returns true when err indicates an HTTP-style 403/"forbidden" response by matching case-insensitive patterns like HTTP 403 or 403 Forbidden; returns false for nil and non-matching errors
IsGoneError func(err error) bool Returns true when err indicates an HTTP-style 410/"gone" response by matching case-insensitive patterns like HTTP 410 or 410 Gone; returns false for nil and non-matching errors

Usage Examples

import "github.com/github/gh-aw/pkg/errorutil"

if errorutil.IsNotFoundError(err) {
    // Handle missing resource path
}

if errorutil.IsForbiddenError(err) {
    // Handle insufficient permissions
}

if errorutil.IsGoneError(err) {
    // Handle expired or deleted resource
}

Dependencies

None.

Design Notes

  • IsNotFoundError, IsForbiddenError, and IsGoneError intentionally accept multiple message formats to cover errors produced by GitHub API responses, gh CLI output, and go-gh wrappers.
  • IsForbiddenError and IsGoneError intentionally require HTTP-style status context so unrelated phrases like forbidden character or gone away are not misclassified.

This specification is automatically maintained by the spec-extractor workflow.

Documentation

Overview

Package errorutil provides shared helpers for classifying and inspecting errors returned by the GitHub API and gh CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsForbiddenError added in v0.74.5

func IsForbiddenError(err error) bool

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

func IsGoneError(err error) bool

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 IsNotFoundError

func IsNotFoundError(err error) bool

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL