MCPcopy Index your code
hub / github.com/cloudfoundry/cli / handleError

Method handleError

util/command_parser/command_parser.go:95–133  ·  view source on GitHub ↗
(passedErr error)

Source from the content-addressed store, hash-verified

93}
94
95func (p *CommandParser) handleError(passedErr error) error {
96 if passedErr == nil {
97 return nil
98 }
99
100 translatedErr := translatableerror.ConvertToTranslatableError(passedErr)
101
102 switch typedErr := translatedErr.(type) {
103 case translatableerror.V3V2SwitchError:
104 log.Info("Received a V3V2SwitchError - switch to the V2 version of the command")
105 return passedErr
106 case TriggerLegacyMain:
107 if typedErr.Error() != "" {
108 p.UI.DisplayWarning("")
109 p.UI.DisplayWarning(typedErr.Error())
110 }
111 cmd.Main(os.Getenv("CF_TRACE"), os.Args)
112 case *ssh.ExitError:
113 exitStatus := typedErr.ExitStatus()
114 if sig := typedErr.Signal(); sig != "" {
115 p.UI.DisplayText("Process terminated by signal: {{.Signal}}. Exited with {{.ExitCode}}", map[string]interface{}{
116 "Signal": sig,
117 "ExitCode": exitStatus,
118 })
119 }
120 return passedErr
121 case translatableerror.CurlExit22Error:
122 p.UI.DisplayError(translatedErr)
123 return passedErr
124 }
125
126 p.UI.DisplayError(translatedErr)
127
128 if _, ok := translatedErr.(DisplayUsage); ok {
129 return ParseErr
130 }
131
132 return ErrFailed
133}
134
135func (p *CommandParser) handleFlagErrorAndCommandHelp(flagErr *flags.Error, flagsParser *flags.Parser, extraArgs []string, originalArgs []string, commandList interface{}) (int, error) {
136 switch flagErr.Type {

Callers 1

executionWrapperMethod · 0.95

Calls 6

MainFunction · 0.92
ErrorMethod · 0.65
DisplayWarningMethod · 0.65
DisplayTextMethod · 0.65
DisplayErrorMethod · 0.65

Tested by

no test coverage detected