MCPcopy Create free account
hub / github.com/cli/cli / FailureReason

Function FailureReason

pkg/cmd/issue/artifact/shared/results.go:114–119  ·  view source on GitHub ↗

FailureReason returns what a result line says about err. The line already names the artifact, so an error from an artifact request gives only the server's message. Other errors, and API errors without a message, give their whole text. That includes an error that wraps an API error, such as a failed

(err error)

Source from the content-addressed store, hash-verified

112// failed --attach upload, whose text names the file. Whitespace is cleaned up
113// so the result stays on one line.
114func FailureReason(err error) string {
115 if httpErr, ok := err.(api.HTTPError); ok && httpErr.HTTPError != nil && httpErr.Message != "" {
116 return text.RemoveExcessiveWhitespace(httpErr.Message)
117 }
118 return text.RemoveExcessiveWhitespace(err.Error())
119}

Callers 4

printFailureFunction · 0.92
TestFailureReasonFunction · 0.85
PrintFailureFunction · 0.85
PrintPartialFailureFunction · 0.85

Calls 2

ErrorMethod · 0.45

Tested by 1

TestFailureReasonFunction · 0.68