You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2025. It is now read-only.
* Handle other ServiceError corner-cases
Improve unmarshalling support for errors that are not OData v4
compliant.
Include raw JSON body when failing to unmarshall into ServiceError.
* refine inner error string case
t.Fatalf("azure: returned nil error for proper error response")
554
557
}
555
558
azErr, _:=err.(*RequestError)
556
-
expected:="autorest/azure: Service returned an error. Status=500 Code=\"InternalError\" Message=\"Conflict\" Details=[{\"code\":\"conflict1\",\"message\":\"error message1\"}]"
559
+
expected:="autorest/azure: Service returned an error. Status=500 Code=\"InternalError\" Message=\"Conflict\" Details=[{\"code\":\"conflict1\",\"message\":\"error message1\"}] InnerError={\"customKey\":\"customValue\"}"
t.Fatalf("azure: returned nil error for proper error response")
588
+
}
589
+
azErr, _:=err.(*RequestError)
590
+
expected:="autorest/azure: Service returned an error. Status=500 Code=\"InternalError\" Message=\"Conflict\" Details=[{\"code\":\"conflict1\",\"message\":\"error message1\"}] InnerError={\"error\":\"something bad happened\"}"
t.Fatalf("azure: returned nil error for proper error response")
620
+
}
621
+
azErr, _:=err.(*RequestError)
622
+
expected:="autorest/azure: Service returned an error. Status=500 Code=\"InternalError\" Message=\"Conflict\" Details=[{\"code\":\"conflict1\",\"message\":\"error message1\"}] InnerError={\"multi\":[{\"customKey\":\"customValue\"},{\"customKey2\":\"customValue2\"}]}"
// here details is a string, it should be an array of objects
630
+
j:=`{
631
+
"error": {
632
+
"code": "InternalError",
633
+
"message": "Conflict",
634
+
"details": "something bad happened"
635
+
}
636
+
}`
637
+
uuid:="71FDB9F4-5E49-4C12-B266-DE7B4FD999A6"
638
+
r:=mocks.NewResponseWithContent(j)
639
+
mocks.SetResponseHeader(r, HeaderRequestID, uuid)
640
+
r.Request=mocks.NewRequest()
641
+
r.StatusCode=http.StatusInternalServerError
642
+
r.Status=http.StatusText(r.StatusCode)
643
+
644
+
err:=autorest.Respond(r,
645
+
WithErrorUnlessStatusCode(http.StatusOK),
646
+
autorest.ByClosing())
647
+
648
+
iferr==nil {
649
+
t.Fatalf("azure: returned nil error for proper error response")
650
+
}
651
+
azErr, _:=err.(*RequestError)
652
+
expected:="autorest/azure: Service returned an error. Status=500 Code=\"InternalError\" Message=\"Conflict\" Details=[{\"raw\":\"something bad happened\"}]"
t.Fatalf("azure: returned nil error for proper error response")
681
+
}
682
+
azErr, _:=err.(*RequestError)
683
+
expected:="autorest/azure: Service returned an error. Status=500 Code=\"InternalError\" Message=\"Conflict\" Details=[{\"code\":\"conflict1\",\"message\":\"error message1\"}] InnerError={\"raw\":500}"
0 commit comments