MCPcopy Create free account
hub / github.com/clouditor/clouditor / HandleResponse

Method HandleResponse

cli/session.go:217–242  ·  view source on GitHub ↗

HandleResponse handles the response and error message of an gRPC call

(msg proto.Message, err error)

Source from the content-addressed store, hash-verified

215
216// HandleResponse handles the response and error message of an gRPC call
217func (*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
244func DefaultArgsShellComp(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
245 return []string{}, cobra.ShellCompDirectiveNoFileComp

Calls

no outgoing calls

Tested by 1