fix: avoid nil pointer (#7508)

Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
This commit is contained in:
屈轩
2020-08-10 10:26:45 +08:00
committed by GitHub
co-authored by Qu Xuan
parent c98e72e6e9
commit 4696a3e475
+4 -2
View File
@@ -167,11 +167,13 @@ type OpenstackError struct {
}
func (ce *OpenstackError) ParseErrorFromJsonResponse(statusCode int, body jsonutils.JSONObject) error {
body.Unmarshal(ce)
if body != nil {
body.Unmarshal(ce)
}
if ce.Code == 0 {
ce.Code = statusCode
}
if len(ce.Details) == 0 {
if len(ce.Details) == 0 && body != nil {
ce.Details = body.String()
}
if len(ce.Class) == 0 {