Skip to content

Commit c73807b

Browse files
committed
优化getConfig返回的异常信息
1 parent 9c8b935 commit c73807b

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# 更新日志
22

3-
## JadeV2.3.6 - 2025-02-26
4-
* get config 如果没有参数时,还是返回异常信息
3+
## JadeV2.3.7 - 2025-05-06
4+
* 优化getConfig返回的异常信息
55
---
66

77
<details onclose>
88
<summary>查看更多更新日志</summary>
99

10+
## JadeV2.3.6 - 2025-02-26
11+
* get config 如果没有参数时,还是返回异常信息
12+
---
13+
1014
## JadeV2.3.5 - 2025-02-11
1115
* 删除jade_tools中的main函数
1216
---

jade/jade_tools.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,24 @@ def getConfig(config, section, configname, default_value=None, config_dic=None,
8888
else:
8989
pass
9090
if default_value is None:
91-
raise e
91+
raise "读取{}参数异常,检查参数是否正常".format(configname)
9292
else:
9393
return default_value
9494

9595

96-
def getBoolConfig(config, section, configname):
96+
def getBoolConfig(config, section, configname, default_value=None,config_dic=None, JadeLog=None):
9797
"""
9898
读取ini参数,强制返回Bool
9999
:param string:
100100
:return:
101101
"""
102-
try:
103-
configparam = (config.get(section, configname)).split("#")[0].rstrip()
104-
except:
105-
print("读取{}参数异常,请检查参数是否正常".format(configname))
106-
sys.exit()
102+
configparam = getConfig(config,section,configname,default_value,config_dic,JadeLog)
107103
if configparam == "False":
108104
return False
109105
elif configparam == "True":
110106
return True
111107
else:
112-
print("读取{}参数异常,参数内容为:{}错误,请检查参数是否正常".format(configname, configparam))
113-
sys.exit()
108+
raise "参数:{}值不合法,请检查参数是否正常,参数值为{}".format(configname,configparam)
114109

115110

116111
def getSectionsConfig(config, section_list, configname):
@@ -120,12 +115,7 @@ def getSectionsConfig(config, section_list, configname):
120115
configparam = (config.get(section, configname)).split("#")[0].rstrip()
121116
config_list.append(configparam)
122117
except Exception as e:
123-
print("读取{}参数异常,请检查参数是否正常,出错原因为 = {},发生异常文件{},发生异常所在的行数{}".format(
124-
configname.e,
125-
e.__traceback__.tb_frame.f_globals[
126-
"__file__"],
127-
e.__traceback__.tb_lineno))
128-
sys.exit()
118+
raise "读取{}参数异常,请检查参数是否正常".format(configname)
129119
return config_list
130120

131121

@@ -144,8 +134,7 @@ def getSectionConfigs(config, section):
144134
for item in itemList:
145135
configsList.append(item[1].split("#")[0].rstrip())
146136
except Exception as e:
147-
print("读取{}参数异常,请检查参数是否正常,异常原因为{}".format(section, e))
148-
sys.exit()
137+
raise "读取{}参数异常,请检查参数是否正常".format(section)
149138
return configsList
150139

151140

0 commit comments

Comments
 (0)