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)
| 112 | // failed --attach upload, whose text names the file. Whitespace is cleaned up |
| 113 | // so the result stays on one line. |
| 114 | func 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 | } |