mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-27 04:37:13 +00:00
feat: 初始化流程异常处理
This commit is contained in:
@@ -133,6 +133,7 @@ def start(first_time_init=False):
|
|||||||
print("更新openai库失败:{}, 请忽略或自行更新".format(e))
|
print("更新openai库失败:{}, 请忽略或自行更新".format(e))
|
||||||
|
|
||||||
known_exception_caught = False
|
known_exception_caught = False
|
||||||
|
try:
|
||||||
try:
|
try:
|
||||||
|
|
||||||
sh = reset_logging()
|
sh = reset_logging()
|
||||||
@@ -255,6 +256,17 @@ def start(first_time_init=False):
|
|||||||
threading.Thread(
|
threading.Thread(
|
||||||
target=run_bot_wrapper
|
target=run_bot_wrapper
|
||||||
).start()
|
).start()
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
if isinstance(e, KeyboardInterrupt):
|
||||||
|
logging.info("程序被用户中止")
|
||||||
|
sys.exit(0)
|
||||||
|
elif isinstance(e, SyntaxError):
|
||||||
|
logging.error("配置文件存在语法错误,请检查配置文件:\n1. 是否存在中文符号\n2. 是否已按照文件中的说明填写正确")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
logging.error("初始化失败:{}".format(e))
|
||||||
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
# 判断若是Windows,输出选择模式可能会暂停程序的警告
|
# 判断若是Windows,输出选择模式可能会暂停程序的警告
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
|||||||
Reference in New Issue
Block a user