A community based topic aggregation platform built on atproto
at main 1.1 kB view raw
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 // ErrConflict indicates the record was modified by another operation (HTTP 409). 22 ErrConflict = errors.New("record was modified by another operation") 23) 24 25// IsAuthError returns true if the error is an authentication/authorization error. 26// This is a convenience function for checking if re-authentication might help. 27func IsAuthError(err error) bool { 28 return errors.Is(err, ErrUnauthorized) || errors.Is(err, ErrForbidden) 29}