Skip to content

Commit

Permalink
Merge pull request #748 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
本地问答库 文本模式补充json文件数据加载异常报错
  • Loading branch information
Ikaros-521 authored Apr 6, 2024
2 parents 85b2125 + 9d0f6e7 commit ef96681
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/my_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,13 @@ def load_data_from_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
return data
except (FileNotFoundError, json.JSONDecodeError):
except json.JSONDecodeError:
logging.error(traceback.format_exc())
logging.error(f"本地问答库 文本模式,JSON文件:{file_path},加载失败,文件JSON格式出错,请进行修改匹配格式!")
return None
except FileNotFoundError:
logging.error(traceback.format_exc())
logging.error(f"本地问答库 文本模式,JSON文件:{file_path}不存在!")
return None

# 从文件加载数据
Expand Down

0 comments on commit ef96681

Please sign in to comment.