better error handling in plugin importing

This commit is contained in:
Kevin F 2022-02-18 14:40:00 -06:00
parent 81a0d83b53
commit d48af45210
1 changed files with 4 additions and 4 deletions

View File

@ -18,6 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
import os, re, importlib import os, re, importlib
import traceback
from . import onionrevents as events from . import onionrevents as events
import config, logger import config, logger
@ -59,9 +60,7 @@ def reload(stop_event = True):
return False return False
def enable(name, start_event = True): def enable(name, start_event = True):
''' """Enable a plugin."""
Enables a plugin
'''
check() check()
@ -73,7 +72,8 @@ def enable(name, start_event = True):
except ImportError as e: # Was getting import error on Gitlab CI test "data" except ImportError as e: # Was getting import error on Gitlab CI test "data"
# NOTE: If you are experiencing issues with plugins not being enabled, it might be this resulting from an error in the module # NOTE: If you are experiencing issues with plugins not being enabled, it might be this resulting from an error in the module
# can happen inconsistently (especially between versions) # can happen inconsistently (especially between versions)
logger.debug('Failed to enable module; Import error: %s' % e) logger.error('Failed to enable module:', terminal=True)
logger.error(traceback.format_exc(), terminal=True)
return False return False
else: else:
enabled_plugins.append(name) enabled_plugins.append(name)