errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines the error types returned by the Kodik API client.

StatusError

StatusError is returned whenever the API responds with an HTTP status code other than 200. It carries the exact code, making it easy to handle specific cases such as rate-limiting (429) or authentication errors (401):

resp, err := api.Search(params)
if err != nil {
    var statusErr *apierrors.StatusError
    if errors.As(err, &statusErr) {
        switch statusErr.Code {
        case http.StatusUnauthorized:
            log.Fatal("invalid API token")
        case http.StatusTooManyRequests:
            log.Fatal("rate limit exceeded")
        default:
            log.Fatalf("API error: HTTP %d", statusErr.Code)
        }
    }
    log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedMethod = errors.New("kodik: unsupported HTTP method")

ErrUnsupportedMethod is returned when an HTTP method other than GET or POST is used.

Functions

This section is empty.

Types

type StatusError

type StatusError struct {
	Code int
}

StatusError is returned when the API responds with a non-200 HTTP status code.

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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