Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/xrpcclient: better errors

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

authored by

Anirudh Oppiliappan and committed by
oppiliappan
ab2bd002 f0b92a26

+11 -5
+11 -5
appview/xrpcclient/xrpc.go
··· 4 4 "bytes" 5 5 "context" 6 6 "errors" 7 - "fmt" 8 7 "io" 9 8 "net/http" 10 9 ··· 11 12 "github.com/bluesky-social/indigo/xrpc" 12 13 indigoxrpc "github.com/bluesky-social/indigo/xrpc" 13 14 oauth "tangled.sh/icyphox.sh/atproto-oauth" 15 + ) 16 + 17 + var ( 18 + ErrXrpcUnsupported = errors.New("xrpc not supported on this knot") 19 + ErrXrpcUnauthorized = errors.New("unauthorized xrpc request") 20 + ErrXrpcFailed = errors.New("xrpc request failed") 21 + ErrXrpcInvalid = errors.New("invalid xrpc request") 14 22 ) 15 23 16 24 type Client struct { ··· 121 115 122 116 var xrpcerr *indigoxrpc.Error 123 117 if ok := errors.As(err, &xrpcerr); !ok { 124 - return fmt.Errorf("Recieved invalid XRPC error response: %v", err) 118 + return ErrXrpcInvalid 125 119 } 126 120 127 121 switch xrpcerr.StatusCode { 128 122 case http.StatusNotFound: 129 - return fmt.Errorf("XRPC is unsupported on this knot, consider upgrading your knot.") 123 + return ErrXrpcUnsupported 130 124 case http.StatusUnauthorized: 131 - return fmt.Errorf("Unauthorized XRPC request.") 125 + return ErrXrpcUnauthorized 132 126 default: 133 - return fmt.Errorf("Failed to perform operation. Try again later.") 127 + return ErrXrpcFailed 134 128 } 135 129 }