AsAPIError converts an error to APIError if it's a gRPC status error, otherwise wraps it as an Internal error
(err error)
| 91 | // AsAPIError converts an error to APIError if it's a gRPC status error, |
| 92 | // otherwise wraps it as an Internal error |
| 93 | func 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 | |
| 109 | func NewMirrorErrorInfo(metadata map[string]string) *rpc.ErrorInfo { |
| 110 | return &rpc.ErrorInfo{ |
nothing calls this directly
no test coverage detected