igerrors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package igerrors defines typed errors returned from Instagram HTTP and JSON responses.

Use errors.As to inspect specific failures (for example TwoFactorRequired, LoginRequired, UserNotFound). MapPrivateHTTPError maps HTTP status and body to these types where applicable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsUserNotFound

func AsUserNotFound(err error, target **UserNotFound) bool

AsUserNotFound sets *target when err unwraps to *UserNotFound.

func CheckStatusFail

func CheckStatusFail(last map[string]any, raw string, endpoint string) error

CheckStatusFail returns ClientError when JSON has status "fail" or includes error_title (HTTP 200 error payloads).

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is HTTP 404 as ClientError or a *UserNotFound.

func MapPrivateHTTPError

func MapPrivateHTTPError(endpoint string, resp *http.Response, body []byte) error

MapPrivateHTTPError maps HTTP status and JSON body to a concrete error type when recognized.

Types

type BadCredentials

type BadCredentials struct {
	Msg string
}

BadCredentials is a local validation error (e.g. missing username).

func (*BadCredentials) Error

func (e *BadCredentials) Error() string

type BadPassword

type BadPassword struct {
	ClientError
}

BadPassword is returned when error_type is bad_password.

type ChallengeRequired

type ChallengeRequired struct {
	ClientError
}

ChallengeRequired indicates Instagram returned challenge_required in the message.

type ClientConnection

type ClientConnection struct {
	ClientError
}

ClientConnection wraps a transport-level failure message.

type ClientError

type ClientError struct {
	Status   int
	Message  string
	Body     map[string]any
	RawBody  string
	Endpoint string
}

ClientError is the base error for Instagram HTTP failures with optional parsed JSON body.

func (*ClientError) Error

func (e *ClientError) Error() string

type ClientJSONDecode

type ClientJSONDecode struct {
	ClientError
}

ClientJSONDecode means the response body was not valid JSON where JSON was expected.

func (*ClientJSONDecode) Error

func (e *ClientJSONDecode) Error() string

type ClientRequestTimeout

type ClientRequestTimeout struct {
	ClientError
}

ClientRequestTimeout wraps HTTP 408.

type ClientThrottled

type ClientThrottled struct {
	ClientError
}

ClientThrottled wraps HTTP 429 responses.

type LoginRequired

type LoginRequired struct {
	ClientError
}

LoginRequired means the session is invalid or absent for the requested resource.

type PleaseWaitFewMinutes

type PleaseWaitFewMinutes struct {
	ClientError
}

PleaseWaitFewMinutes is returned when the message asks to wait before retrying.

type PrivateAccount

type PrivateAccount struct {
	ClientError
}

PrivateAccount means the viewer cannot access a private profile's data.

type RateLimitError

type RateLimitError struct {
	ClientError
}

RateLimitError is a structured rate limit response from the API.

type TwoFactorRequired

type TwoFactorRequired struct {
	ClientError
	TwoFactorIdentifier string
}

TwoFactorRequired indicates the account needs a second factor; TwoFactorIdentifier may be set from the response.

type UserNotFound

type UserNotFound struct {
	ClientError
	Username string
	UserID   string
}

UserNotFound means the user does not exist or cannot be loaded.

Jump to

Keyboard shortcuts

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