error fix
@@ -32,6 +32,7 @@ const (
InvalidRequestFormat = "InvalidRequestFormat"
KeyNotFound = "KeyNotFound"
InvalidParameters = "InvalidParameters"
+ CannotParseError = "CannotParseError"
)
func NewAzureError(err error) error {
@@ -47,11 +48,21 @@ func NewAzureError(err error) error {
ae.Code = det.StatusCode.(int)
if e, ok := det.Original.(*azure.RequestError); ok {
+ if e.ServiceError != nil {
kind = e.ServiceError.Code
reason = e.ServiceError.Message
+ } else {
+ kind = CannotParseError
+ reason = CannotParseError
+ }
} else if e, ok := det.Original.(azure.RequestError); ok {
+ if e.ServiceError != nil {
kind = e.ServiceError.Code
reason = e.ServiceError.Message
+ } else {
+ kind = CannotParseError
+ reason = CannotParseError
+ }
} else if e, ok := det.Original.(*azure.ServiceError); ok {
kind = e.Code
reason = e.Message
