MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / handleErrString

Function handleErrString

agent/utils/cmd/cmdx.go:522–543  ·  view source on GitHub ↗
(stdout, stderr string, ignoreExist1 bool, err error)

Source from the content-addressed store, hash-verified

520}
521
522func handleErrString(stdout, stderr string, ignoreExist1 bool, err error) (string, error) {
523 var exitError *exec.ExitError
524 if ignoreExist1 && errors.As(err, &exitError) {
525 if status, ok := exitError.Sys().(syscall.WaitStatus); ok {
526 if status.ExitStatus() == 1 {
527 return "", nil
528 }
529 }
530 }
531 outItem := stdout
532 errItem := stderr
533 if len(errItem) != 0 && len(outItem) != 0 {
534 return outItem, fmt.Errorf("stdout: %s; stderr: %s, err: %v", outItem, errItem, err)
535 }
536 if len(errItem) != 0 {
537 return outItem, fmt.Errorf("stderr: %s, err: %v", errItem, err)
538 }
539 if len(outItem) != 0 {
540 return outItem, fmt.Errorf("stdout: %s, err: %v", outItem, err)
541 }
542 return "", err
543}

Callers 3

RunPipeMethod · 0.70
RunPipeToFileMethod · 0.70
handleErrFunction · 0.70

Calls 1

SysMethod · 0.80

Tested by

no test coverage detected