Commit 3b2854a5978a028e90140366ee6be0290a10d5a8
1 parent
3fa255ca
Exists in
master
提交
Showing
1 changed file
with
11 additions
and
11 deletions
Show diff stats
src/HttpServer/logic/httpserver.go
@@ -36,6 +36,15 @@ func CheckErr(err error) { | @@ -36,6 +36,15 @@ func CheckErr(err error) { | ||
36 | } | 36 | } |
37 | 37 | ||
38 | func startServerHttpServe() { | 38 | func startServerHttpServe() { |
39 | + defer func() { | ||
40 | + //recover() //可以打印panic的错误信息 | ||
41 | + //fmt.Println(recover()) | ||
42 | + if err := recover(); err != nil { //产生了panic异常 | ||
43 | + fmt.Println(err) | ||
44 | + } | ||
45 | + | ||
46 | + }() //别忘了(), 调用此匿名函数 | ||
47 | + | ||
39 | //------------------------------------------------------------- | 48 | //------------------------------------------------------------- |
40 | http.HandleFunc("/catcafe/ClearData", ClearData) //情况账号的测试接口 | 49 | http.HandleFunc("/catcafe/ClearData", ClearData) //情况账号的测试接口 |
41 | http.HandleFunc("/catcafe/AddWhiteList", AddWhiteList) //情况账号的测试接口 | 50 | http.HandleFunc("/catcafe/AddWhiteList", AddWhiteList) //情况账号的测试接口 |
@@ -88,22 +97,13 @@ func checkFileIsExist(filename string) bool { | @@ -88,22 +97,13 @@ func checkFileIsExist(filename string) bool { | ||
88 | 97 | ||
89 | func QueryAllAccount(w http.ResponseWriter, r *http.Request) { | 98 | func QueryAllAccount(w http.ResponseWriter, r *http.Request) { |
90 | 99 | ||
91 | - logger.Info("QueryAllAccount ") | ||
92 | - | ||
93 | - | ||
94 | - defer func() { | ||
95 | - //recover() //可以打印panic的错误信息 | ||
96 | - //fmt.Println(recover()) | ||
97 | - if err := recover(); err != nil { //产生了panic异常 | ||
98 | - fmt.Println(err) | ||
99 | - } | ||
100 | - | ||
101 | - }() //别忘了(), 调用此匿名函数 | ||
102 | type A struct { | 100 | type A struct { |
103 | a int | 101 | a int |
104 | } | 102 | } |
105 | var a *A | 103 | var a *A |
106 | a.a = 1 | 104 | a.a = 1 |
105 | + logger.Info("QueryAllAccount ") | ||
106 | + | ||
107 | 107 | ||
108 | //先打开文件 | 108 | //先打开文件 |
109 | filename := "./data.txt" | 109 | filename := "./data.txt" |