Something went wrong. Try again.
Go boilerplate library for building atproto apps
atproto go
Something went wrong. Try again.
atp errors.go
737 B · 27 lines
Go
at jetstream-v2
12345678910111213141516171819202122232425262728package atp
import ( "errors" "fmt" "strings")
// ErrSessionExpired indicates the OAuth session can no longer be resumed.// Callers should prompt the user to re-authenticate.var ErrSessionExpired = errors.New("oauth session expired")
// WrapPDSError inspects an XRPC error for signals that the OAuth grant is no// longer valid and, if so, wraps it with ErrSessionExpired.// TODO: handle other common error typesfunc WrapPDSError(err error) error { if err == nil { return nil } msg := err.Error() if strings.Contains(msg, "invalid_grant") || strings.Contains(msg, "failed to refresh OAuth tokens") || strings.Contains(msg, "token is expired") { return fmt.Errorf("%w: %w", ErrSessionExpired, err) } return err}