Skip to content

Commit 63905fd

Browse files
committed
Update the error messages
1 parent e905937 commit 63905fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backend/utils/import_parse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def dynamic_import_data_model(module_path: str) -> Type[T]:
3434
module_path, class_name = module_path.rsplit('.', 1)
3535
module = import_module_cached(module_path)
3636
return getattr(module, class_name)
37-
except (ImportError, AttributeError) as e:
37+
except Exception as e:
3838
log.error(f'动态导入数据模型失败:{e}')
3939
raise errors.ServerError(msg='数据模型列动态解析失败,请联系系统超级管理员')
4040

@@ -43,16 +43,16 @@ def get_model_object(module_path: str) -> type | None:
4343
"""
4444
获取模型对象
4545
46-
:param module_path: 模块路径,格式为 'module_path.class_name'
46+
:param module_path: 模块路径
4747
:return:
4848
"""
4949
try:
5050
module = import_module_cached(module_path)
5151
except ModuleNotFoundError:
52-
log.warning(f'模块 {module_path} 中不包含 model 对象')
52+
log.warning(f'模块 {module_path} 中不包含模型对象')
5353
return None
5454
except Exception as e:
55-
raise RuntimeError(f'模块 {module_path} 导入失败{e}')
55+
raise RuntimeError(f'获取模块 {module_path} 模型对象失败{e}')
5656

5757
for name, obj in inspect.getmembers(module):
5858
if inspect.isclass(obj):

0 commit comments

Comments
 (0)