Skip to content

Commit

Permalink
support when statusCode is *int
Browse files Browse the repository at this point in the history
  • Loading branch information
yndu13 authored and peze committed Jun 20, 2022
1 parent af66437 commit 3a75a83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tea/tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func NewSDKError(obj map[string]interface{}) *SDKError {
if err_ == nil {
err.StatusCode = Int(code)
}
} else if code, ok := statusCode.(*int); ok {
err.StatusCode = code
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions tea/tea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ func TestSDKError(t *testing.T) {
utils.AssertNotNil(t, err)
utils.AssertEqual(t, 500, *err.StatusCode)

err = NewSDKError(map[string]interface{}{
"data": map[string]interface{}{
"statusCode": Int(500),
},
})
utils.AssertNotNil(t, err)
utils.AssertEqual(t, 500, *err.StatusCode)

err = NewSDKError(map[string]interface{}{
"data": map[string]interface{}{
"statusCode": "500",
Expand Down

0 comments on commit 3a75a83

Please sign in to comment.