catch all exceptions during import of usermodels.py; closes #149
This commit is contained in:
parent
64b270d7c1
commit
d18b3ee671
@ -6,6 +6,7 @@ from nmreval.configs import config_paths
|
||||
from nmreval import models
|
||||
from nmreval.lib.importer import find_models
|
||||
from nmreval.lib.colors import BaseColor, Tab10
|
||||
from nmreval.lib.logger import logger
|
||||
from nmreval.utils.text import convert
|
||||
|
||||
from ..lib.iconloading import get_icon
|
||||
@ -50,8 +51,14 @@ class QFunctionWidget(QtWidgets.QWidget, Ui_Form):
|
||||
user_defined = []
|
||||
try:
|
||||
user_defined = find_models(config_paths() / 'usermodels.py')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception as e:
|
||||
import traceback
|
||||
_ = QtWidgets.QMessageBox.warning(
|
||||
self,
|
||||
'No user functions',
|
||||
f'Loading user-defined function failed with exception:\n'
|
||||
f'{"".join(traceback.format_exception(e, limit=1))}')
|
||||
logger.exception("Invalid usermodels.py", exc_info=e)
|
||||
|
||||
for model in user_defined:
|
||||
name = model.__name__
|
||||
|
Loading…
Reference in New Issue
Block a user