Documentation
¶
Index ¶
- func AssignValue(obj interface{}, jsonName string, value interface{})
- func BodyReader(response runtime.ClientResponse)
- func Exit(msg string, err error)
- func GetFieldValue(obj interface{}, jsonName string) reflect.Value
- func HumanizeAPIError(err error) string
- func PrintError(err error)
- func Render(data []renderer.ResponseData)
- func Singular(str string) string
- func TitleStr(str string) string
- func Untar(source, destination string) error
- func Unzip(source, destination string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignValue ¶
func AssignValue(obj interface{}, jsonName string, value interface{})
func BodyReader ¶
func BodyReader(response runtime.ClientResponse)
func GetFieldValue ¶
func HumanizeAPIError ¶ added in v1.6.1
HumanizeAPIError rewrites generic SDK error strings into messages that tell the user what to do next. Falls back to err.Error() when nothing more specific is recognized.
Detection keys off the bracketed "[<status>]" status marker that the go-openapi runtime puts on its errors. Two shapes occur in practice:
[401] Unauthorized &{...} // generic response
[POST /servers][401] createServerUnauthorized ... // typed response
so the marker shows up either at the start of the string or right after the "[<method> <path>]" segment. Matching "[401]" only at those two anchors (start, or after a "]") catches both shapes while ignoring a bare "[401]" that merely appears inside an error payload. Matching loose words like "unauthorized" is avoided too — it would capture unrelated validation messages such as `"field 'role' has an unauthorized value"`.
func PrintError ¶
func PrintError(err error)
PrintError prints a formatted error. Recognized API failures are rewritten as actionable guidance for the user (e.g. 401 → "run lsh login").
Types ¶
This section is empty.