Compare commits

..

3 Commits

Author SHA1 Message Date
peze c032b7c3e5 compatible with old err 2025-03-12 15:51:16 +08:00
peze 171239d819 compatible with old err 2025-03-11 21:08:20 +08:00
peze 4f3624270b add to writer 2025-03-11 21:08:20 +08:00
2 changed files with 13 additions and 17 deletions
+13 -16
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/alibabacloud-go/tea/tea"
"net/http"
"reflect"
"strconv"
@@ -42,40 +41,38 @@ type CastError struct {
Message *string
}
func TeaSDKError(err error) *tea.SDKError {
if err == nil {
func TeaSDKError(err error) error {
if(err == nil) {
return nil
}
if te, ok := err.(*SDKError); ok {
return tea.NewSDKError(map[string]interface{}{
"code": StringValue(te.Code),
"statusCode": IntValue(te.StatusCode),
"message": StringValue(te.Message),
"data": te.Data,
"description": StringValue(te.Description),
"code": StringValue(te.Code),
"statusCode": IntValue(te.StatusCode),
"message": StringValue(te.Message),
"data": te.Data,
"description": StringValue(te.Description),
"accessDeniedDetail": te.AccessDeniedDetail,
})
}
if respErr, ok := err.(ResponseError); ok {
if respErr, ok := err.(ResponseError); ok {
return tea.NewSDKError(map[string]interface{}{
"code": StringValue(respErr.GetCode()),
"code": StringValue(respErr.GetCode()),
"statusCode": IntValue(respErr.GetStatusCode()),
"message": respErr.Error(),
"message": respErr.Error(),
})
}
if baseErr, ok := err.(BaseError); ok {
if baseErr, ok := err.(BaseError); ok {
return tea.NewSDKError(map[string]interface{}{
"code": StringValue(baseErr.GetCode()),
"code": StringValue(baseErr.GetCode()),
"message": baseErr.Error(),
})
}
return tea.NewSDKError(map[string]interface{}{
"message": err.Error(),
})
return err
}
// NewSDKError is used for shortly create SDKError object
-1
View File
@@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"strings"