HandleResponse handles the response and error message of an gRPC call
(msg proto.Message, err error)
| 215 | |
| 216 | // HandleResponse handles the response and error message of an gRPC call |
| 217 | func (*Session) HandleResponse(msg proto.Message, err error) error { |
| 218 | if err != nil { |
| 219 | // check, if it is a gRPC error |
| 220 | s, ok := status.FromError(err) |
| 221 | |
| 222 | // otherwise, forward the error message |
| 223 | if !ok { |
| 224 | return err |
| 225 | } |
| 226 | |
| 227 | // create a new error with just the message |
| 228 | return errors.New(s.Message()) |
| 229 | } |
| 230 | |
| 231 | opt := protojson.MarshalOptions{ |
| 232 | Multiline: true, |
| 233 | Indent: " ", |
| 234 | EmitUnpopulated: true, |
| 235 | } |
| 236 | |
| 237 | b, _ := opt.Marshal(msg) |
| 238 | |
| 239 | _, err = fmt.Fprintf(Output, "%s\n", string(b)) |
| 240 | |
| 241 | return err |
| 242 | } |
| 243 | |
| 244 | func DefaultArgsShellComp(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { |
| 245 | return []string{}, cobra.ShellCompDirectiveNoFileComp |
no outgoing calls