From d25e32023882e709d970568cddaa4711916e7dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E8=91=89=E6=9D=8F?= Date: Thu, 4 Jan 2024 17:54:12 +0800 Subject: [PATCH] fix: log error when reading version file. (#2503) --- cmd/gocq/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/gocq/main.go b/cmd/gocq/main.go index c24562a35..eab89f62b 100644 --- a/cmd/gocq/main.go +++ b/cmd/gocq/main.go @@ -255,8 +255,14 @@ func LoginInteract() { versionFile := path.Join(global.VersionsPath, fmt.Sprint(int(cli.Device().Protocol))+".json") if global.PathExists(versionFile) { b, err := os.ReadFile(versionFile) - if err == nil { - _ = cli.Device().Protocol.Version().UpdateFromJson(b) + if err != nil { + log.Warnf("从文件 %s 读取本地版本信息文件出错.", versionFile) + os.Exit(0) + } + err = cli.Device().Protocol.Version().UpdateFromJson(b) + if err != nil { + log.Warnf("从文件 %s 解析本地版本信息出错: %v", versionFile, err) + os.Exit(0) } log.Infof("从文件 %s 读取协议版本 %v.", versionFile, cli.Device().Protocol.Version()) }