forked from huaweicloud/huaweicloud-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
41 lines (34 loc) · 866 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cloudservers
import (
"encoding/json"
"fmt"
)
type errorObj struct {
Code string `json:"code"`
Message string `json:"message"`
}
type internalErr struct {
ID string `json:"id"`
ErrorCode string `json:"error_code"`
ErrorMessage string `json:"error_message"`
}
type BatchOperateError struct {
BasicError errorObj `json:"error"`
InternalError []internalErr `json:"internalError"`
}
//Error,Implement the Error() interface.
func (e BatchOperateError) Error() string {
data, err := json.Marshal(e)
if err != nil {
return fmt.Sprintf(err.Error())
}
return fmt.Sprintf(string(data))
}
//ErrorCode,Error code converted to string type.
func (e BatchOperateError) ErrorCode() string {
return e.BasicError.Code
}
//Message,Return error message.
func (e BatchOperateError) Message() string {
return e.BasicError.Message
}