Make the error slightly more readable

This commit is contained in:
Maciej Szulik 2019-04-24 15:14:17 +02:00
parent 3ba70b9b5e
commit 825cb677bf
No known key found for this signature in database
GPG Key ID: F15E55D276FA84C4

View File

@ -132,6 +132,9 @@ func checkErr(err error, handleErr func(string, int)) {
case kerrors.IsInvalid(err):
details := err.(*kerrors.StatusError).Status().Details
s := fmt.Sprintf("The %s %q is invalid", details.Kind, details.Name)
if len(details.Kind) == 0 && len(details.Name) == 0 {
s = "The request is invalid"
}
if len(details.Causes) > 0 {
errs := statusCausesToAggrError(details.Causes)
handleErr(MultilineError(s+": ", errs), DefaultErrorExitCode)