A community based topic aggregation platform built on atproto
1package pds
2
3import "errors"
4
5// Typed errors for PDS operations.
6// These allow services to use errors.Is() for reliable error detection
7// instead of fragile string matching.
8var (
9 // ErrUnauthorized indicates the request failed due to invalid or expired credentials (HTTP 401).
10 ErrUnauthorized = errors.New("unauthorized")
11
12 // ErrForbidden indicates the request was rejected due to insufficient permissions (HTTP 403).
13 ErrForbidden = errors.New("forbidden")
14
15 // ErrNotFound indicates the requested resource does not exist (HTTP 404).
16 ErrNotFound = errors.New("not found")
17
18 // ErrBadRequest indicates the request was malformed or invalid (HTTP 400).
19 ErrBadRequest = errors.New("bad request")
20)
21
22// IsAuthError returns true if the error is an authentication/authorization error.
23// This is a convenience function for checking if re-authentication might help.
24func IsAuthError(err error) bool {
25 return errors.Is(err, ErrUnauthorized) || errors.Is(err, ErrForbidden)
26}