Skip to content

Add try/except around all plugin loads#55

Open
tbttfox wants to merge 2 commits intoblurstudio:mainfrom
tbttfox:wrap-plugin-load
Open

Add try/except around all plugin loads#55
tbttfox wants to merge 2 commits intoblurstudio:mainfrom
tbttfox:wrap-plugin-load

Conversation

@tbttfox
Copy link
Member

@tbttfox tbttfox commented Feb 22, 2026

Checklist

  • I have read the CONTRIBUTING.md document
  • I formatted my changes with black
  • I linted my changes with flake8
  • I have added documentation regarding my changes where necessary
  • Any pre-existing tests continue to pass
  • Additional tests were made covering my changes

Types of Changes

  • Bugfix (change that fixes an issue)
  • New Feature (change that adds functionality)
  • Documentation Update (if none of the other choices apply)

Proposed Changes

We can't trust plugins to load, so wrap all entry point loads in a try/except block.
Note: If we try to run preditor for the first time in a python instance that doesn't have QScintilla installed, it will crash because it tries to load the scintilla workbox.

try:
return plug_name, ep.load()
except Exception:
_logger.warning('Unable to load editor {}'.format(ep.name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you want to see the traceback as part of this logging message instead of just logging the plugin name?

_logger.warning('Unable to load editor {}'.format(ep.name), exc_info=True)

import logging
try:
    raise Exception("The plugin failed for reasons")
except Exception:
    logging.warning("unable to init plugin", exc_info=True)

output:

WARNING:root:unable to init plugin
Traceback (most recent call last):
  File "<WorkboxSelection>:misc/Workbox46", line 17, in <module>
Exception: The plugin failed for reasons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants