-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
56 lines (45 loc) · 1.3 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2021. Homeland Interactive Technology Ltd. All rights reserved.
package ruixuego
import "errors"
var (
ErrInvalidDevicecode = errors.New("invalid devicecode or distinctid")
ErrInvalidEvent = errors.New("invalid event")
ErrInvalidCPID = errors.New("invalid cpid")
ErrInvalidOpenID = errors.New("invalid openid")
ErrInvalidProductID = errors.New("invalid productid")
ErrAppKeyNotExistx = errors.New("appkey not exists")
ErrInvalidType = errors.New("invalid type")
ErrInvalidIMSConversationID = errors.New("invalid ims conversation id")
ErrInvalidParam = errors.New("invalid param")
ErrInvalidCPuserID = errors.New("invalid cp_user_id")
errProducerShutdown = errors.New("producer already shut down")
)
type Error struct {
traceID string
err string
}
func (e *Error) Error() string {
return e.err
}
func errWithTraceID(err error, traceID string) error {
if err == nil {
return nil
}
return &Error{
traceID: traceID,
err: err.Error(),
}
}
// ErrTraceID 返回发生错误的 TraceID
func ErrTraceID(err error) string {
if err == nil {
return ""
}
if e, ok := err.(*Error); ok {
return e.traceID
}
if e := errors.Unwrap(err); e != nil {
return ErrTraceID(e)
}
return ""
}