MCPcopy Index your code
hub / github.com/PeerDB-io/peerdb / AsAPIError

Function AsAPIError

flow/cmd/api_error.go:93–107  ·  view source on GitHub ↗

AsAPIError converts an error to APIError if it's a gRPC status error, otherwise wraps it as an Internal error

(err error)

Source from the content-addressed store, hash-verified

91// AsAPIError converts an error to APIError if it's a gRPC status error,
92// otherwise wraps it as an Internal error
93func AsAPIError(err error) APIError {
94 if err == nil {
95 return nil
96 }
97
98 if apiErr, ok := err.(APIError); ok {
99 return apiErr
100 }
101
102 if s, ok := status.FromError(err); ok {
103 return newAPIError(s)
104 }
105
106 return NewInternalApiError(err)
107}
108
109func NewMirrorErrorInfo(metadata map[string]string) *rpc.ErrorInfo {
110 return &rpc.ErrorInfo{

Callers

nothing calls this directly

Calls 2

newAPIErrorFunction · 0.85
NewInternalApiErrorFunction · 0.85

Tested by

no test coverage detected