MCPcopy Create free account
hub / github.com/apache/camel-k / parseErrorHandler

Method parseErrorHandler

pkg/cmd/bind.go:288–316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

286}
287
288func (o *bindCmdOptions) parseErrorHandler() (*v1.ErrorHandlerSpec, error) {
289 errHandlMap := make(map[string]any)
290 errHandlType, errHandlValue, err := parseErrorHandlerByType(o.ErrorHandler)
291 if err != nil {
292 return nil, err
293 }
294 switch errHandlType {
295 case "none":
296 errHandlMap["none"] = nil
297 case "log":
298 errHandlMap["log"] = nil
299 case "sink":
300 sinkSpec, err := o.decode(errHandlValue, errorHandlerKey)
301 if err != nil {
302 return nil, err
303 }
304 errHandlMap["sink"] = map[string]any{
305 "endpoint": sinkSpec,
306 }
307 default:
308 return nil, fmt.Errorf("invalid error handler type %s", o.ErrorHandler)
309 }
310 errHandlMarshalled, err := json.Marshal(&errHandlMap)
311 if err != nil {
312 return nil, err
313 }
314
315 return &v1.ErrorHandlerSpec{RawMessage: errHandlMarshalled}, nil
316}
317
318func parseErrorHandlerByType(value string) (string, string, error) {
319 errHandlSplit := strings.SplitN(value, ":", 2)

Callers 1

runMethod · 0.95

Calls 3

decodeMethod · 0.95
parseErrorHandlerByTypeFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected