-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy patherror_test.go
More file actions
51 lines (46 loc) · 1.47 KB
/
error_test.go
File metadata and controls
51 lines (46 loc) · 1.47 KB
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
package logger
import (
"errors"
"fmt"
"testing"
)
func TestNewError(t *testing.T) {
e := NewError("error reason 1", PARAM_EMAIL)
fmt.Println("error:", e.Error()) //
fmt.Println("errInfo", e.ErrorInfo())
fmt.Println("detail", e.Detail())
fmt.Println("format", e.Format())
fmt.Println("stack", e.Stack())
}
func TestNewErrorWithError(t *testing.T) {
err := errors.New("this is error reason")
e := NewError(err, PARAM_EMAIL)
fmt.Println("error:", e.Error()) //10400|邮箱错误
fmt.Println("errInfo", e.ErrorInfo()) //this is error reason
fmt.Println("detail", e.Detail()) //(error_test.go:20)this is error reason
fmt.Println("format", e.Format()) //10400 邮箱错误 error_test.go 20 this is error reason
fmt.Println("stack", e.Stack())
}
func TestNewErrorRpcx(t *testing.T) {
//rpc server
serverE := NewError("mysql error", PARAM_EMAIL)
err := errors.New(serverE.Error())
//rpc client revieve err
e := NewError(err) //PARAM_EMAIL
fmt.Println("error:", e.Error())
fmt.Println("errInfo", e.ErrorInfo())
fmt.Println("detail", e.Detail())
fmt.Println("format", e.Format())
fmt.Println("stack", e.Stack())
}
func TestNewErrorRpcx2(t *testing.T) {
//rpc client call error
err := errors.New("network eof")
//rpc client revieve err
e := NewError(err) //SYSTEM_DEFAUT
fmt.Println("error:", e.Error())
fmt.Println("errInfo", e.ErrorInfo())
fmt.Println("detail", e.Detail())
fmt.Println("format", e.Format())
fmt.Println("stack", e.Stack())
}