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 ¶
- func AsUserNotFound(err error, target **UserNotFound) bool
- func CheckStatusFail(last map[string]any, raw string, endpoint string) error
- func IsNotFound(err error) bool
- func MapPrivateHTTPError(endpoint string, resp *http.Response, body []byte) error
- type BadCredentials
- type BadPassword
- type ChallengeRequired
- type ClientConnection
- type ClientError
- type ClientJSONDecode
- type ClientRequestTimeout
- type ClientThrottled
- type LoginRequired
- type PleaseWaitFewMinutes
- type PrivateAccount
- type RateLimitError
- type TwoFactorRequired
- type UserNotFound
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 ¶
CheckStatusFail returns ClientError when JSON has status "fail" or includes error_title (HTTP 200 error payloads).
func IsNotFound ¶
IsNotFound reports whether err is HTTP 404 as ClientError or a *UserNotFound.
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.