Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
优化代码报错输出内容,方便更加详细的判断是服务器错误还是工具本身的代码错误
Browse files Browse the repository at this point in the history
  • Loading branch information
rootphantomer committed Oct 12, 2022
1 parent 894c847 commit b4fffa7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ rust 项目代码 移步这里——<https://github.com/360quake/quake_rs/>

## 更新日志

- 2022-10-12 v2.0.3:

- 优化代码逻辑
- 优化代码报错输出内容,方便更加详细的判断是服务器错误还是工具本身的代码错误

- 2022-10-02 v2.0.2:

- 修复search空格被吃掉的问题
- 增加命令后颜色输出
- 修复search空格被吃掉的问题
- 增加命令后颜色输出

- 2022-09-28 v2.0.1:

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func action(num int) {
}
switch strings.ToLower(hflag.GetString("option")) {
case "version":
successColor.Println("version:2.0.2")
successColor.Println("version:2.0.3")
case "init":
if num < 3 {
errorColor.Println("!!!!token is empty !!!!")
Expand Down
19 changes: 15 additions & 4 deletions utils/LoadJson.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ package utils
import (
"encoding/json"
"fmt"
"os"
)

func RespLoadJson[T any](body string) (respjson T) {
if err := json.Unmarshal([]byte(body), &respjson); err != nil {
fmt.Println(body)
panic(err)
//panic(err)
os.Exit(0)
}
return
}
Expand All @@ -28,9 +30,18 @@ func InfoLoadJson(body string) (data map[string]interface{}, user map[string]int
var infomapjson map[string]interface{}
if err := json.Unmarshal([]byte(body), &infomapjson); err != nil {
fmt.Println(body)
panic(err)
//panic(err)
os.Exit(0)
}
data, ok := infomapjson["data"].(map[string]interface{})
if !ok {
fmt.Println(infomapjson)
os.Exit(0)
}
user, ok = data["user"].(map[string]interface{})
if !ok {
fmt.Println(infomapjson)
os.Exit(0)
}
data = infomapjson["data"].(map[string]interface{})
user = data["user"].(map[string]interface{})
return
}

0 comments on commit b4fffa7

Please sign in to comment.