Skip to content

Commit 5f26718

Browse files
author
Simple-Tracker
committed
Improve error message of GenJSON
1 parent 05477fc commit 5f26718

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func SetBlockListFromFile() bool {
268268
if filepath.Ext(filePath) == ".json" {
269269
err = json.Unmarshal(blockListContent, &content)
270270
if err != nil {
271-
Log("SetBlockListFromFile", GetLangText("Error-GenJSON"), true, filePath)
271+
Log("SetBlockListFromFile", GetLangText("Error-GenJSONWithID"), true, filePath, err.Error())
272272
continue
273273
}
274274
} else {
@@ -307,7 +307,7 @@ func SetBlockListFromURL() bool {
307307
if strings.HasSuffix(strings.ToLower(strings.Split(httpHeader.Get("Content-Type"), ";")[0]), "json") {
308308
err := json.Unmarshal(blockListContent, &content)
309309
if err != nil {
310-
Log("SetBlockListFromFile", GetLangText("Error-GenJSON"), true, blockListURL)
310+
Log("SetBlockListFromFile", GetLangText("Error-GenJSONWithID"), true, blockListURL, err.Error())
311311
continue
312312
}
313313
} else {
@@ -382,7 +382,7 @@ func SetIPBlockListFromFile() bool {
382382
if filepath.Ext(filePath) == ".json" {
383383
err := json.Unmarshal(ipBlockListFile, &content)
384384
if err != nil {
385-
Log("SetIPBlockListFromFile", GetLangText("Error-GenJSON"), true, filePath)
385+
Log("SetIPBlockListFromFile", GetLangText("Error-GenJSONWithID"), true, filePath, err.Error())
386386
}
387387
} else {
388388
content = strings.Split(string(ipBlockListFile), "\n")
@@ -418,7 +418,7 @@ func SetIPBlockListFromURL() bool {
418418
if strings.HasSuffix(httpHeader.Get("Content-Type"), "json") {
419419
err := json.Unmarshal(ipBlockListContent, &content)
420420
if err != nil {
421-
Log("SetIPBlockListFromURL", GetLangText("Error-GenJSON"), true, ipBlockListURL)
421+
Log("SetIPBlockListFromURL", GetLangText("Error-GenJSONWithID"), true, ipBlockListURL, err.Error())
422422
continue
423423
}
424424
} else {

i18n.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ var defaultLangContent = map[string]string{
7878
"Error-Login": "登录时发生了错误",
7979
"Error-FetchUpdate": "获取更新时发生了错误",
8080
"Error-GenJSON": "构造 JSON 时发生了错误: %s",
81+
"Error-GenJSONWithID": "构造 JSON (%s) 时发生了错误: %s",
8182
"Error-Log_Write": "写入日志时发生了错误: %s",
8283
"Error-IPFilter_Write": "写入 IPFilter 时发生了错误: %s",
8384
"Error-LoadLog_Mkdir": "创建日志目录时发生了错误: %s",

lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Error-Login": "An error occurred while logging in",
6868
"Error-FetchUpdate": "An error occurred while fetching update",
6969
"Error-GenJSON": "An error occurred while generate JSON: %s",
70+
"Error-GenJSONWithID": "An error occurred while generate JSON (%s): %s",
7071
"Error-Log_Write": "An error occurred while writing to log: %s",
7172
"Error-IPFilter_Write": "An error occurred while writing to IPFilter: %s",
7273
"Error-LoadLog_Mkdir": "An error occurred while creating log directory: %s",

0 commit comments

Comments
 (0)