Change Format of API Error (#784)
This is a wire breaking change for json errors since we have removed and renamed a few fields, and changed part of the structure of the returned json error. * Remove redundant fields in Status, details.error_id, details.TraceId and details.request_id from API errors. * Added wrapped errors and "ops" field to indicate the internal operation of the errors returned by the API. * Added error cli error reporting of Op and wrapped errors.
This commit is contained in:
1 parent
18ea39b237
commit
aa4157639c
48 files changed
+742
-728
No files matched your search
+18
-12
@@ -136,20 +136,13 @@ func WrapMap(prefixSpaces, maxLengthOverride int, input map[string]interface{})
|
||||
|
||||
func PrintApiError(in *api.Error) string {
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"Status": in.Status,
|
||||
"Code": in.Code,
|
||||
"Status": in.ResponseStatus(),
|
||||
"Kind": in.Kind,
|
||||
"Message": in.Message,
|
||||
}
|
||||
if in.Details != nil {
|
||||
if in.Details.TraceId != "" {
|
||||
nonAttributeMap["Trace ID"] = in.Details.TraceId
|
||||
}
|
||||
if in.Details.RequestId != "" {
|
||||
nonAttributeMap["Request ID"] = in.Details.RequestId
|
||||
}
|
||||
if in.Details.ErrorId != "" {
|
||||
nonAttributeMap["Error ID"] = in.Details.ErrorId
|
||||
}
|
||||
|
||||
if in.Op != "" {
|
||||
nonAttributeMap["Operation"] = in.Op
|
||||
}
|
||||
|
||||
maxLength := MaxAttributesLength(nonAttributeMap, nil, nil)
|
||||
@@ -161,6 +154,19 @@ func PrintApiError(in *api.Error) string {
|
||||
}
|
||||
|
||||
if in.Details != nil {
|
||||
if len(in.Details.WrappedErrors) > 0 {
|
||||
ret = append(ret,
|
||||
"",
|
||||
" Wrapped Errors:",
|
||||
)
|
||||
for _, we := range in.Details.WrappedErrors {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Message: %s", we.Message),
|
||||
fmt.Sprintf(" Operation: %s", we.Op),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if len(in.Details.RequestFields) > 0 {
|
||||
ret = append(ret,
|
||||
"",
|
||||
|
||||
Reference in new issue
Block a user