Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace system errors #529

Merged
merged 7 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions envisage/composite_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def start_plugin(self, plugin=None, plugin_id=None):
logger.debug("plugin %s started", plugin.id)

else:
raise SystemError("no such plugin %s" % plugin_id)
raise ValueError("no such plugin %s" % plugin_id)

def stop(self):
""" Stop the plugin manager. """
Expand All @@ -177,4 +177,4 @@ def stop_plugin(self, plugin=None, plugin_id=None):
logger.debug("plugin %s stopped", plugin.id)

else:
raise SystemError("no such plugin %s" % plugin_id)
raise ValueError("no such plugin %s" % plugin_id)
2 changes: 1 addition & 1 deletion envisage/egg_basket_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _harvest_plugins_in_eggs(self, application):
def _handle_broken_distributions(self, errors):
logger.error("Error loading distributions: %s", errors)
if self.on_broken_distribution is None:
raise SystemError("Cannot find eggs %s" % errors)
raise RuntimeError("Cannot find compatible eggs %s" % errors)
mdickinson marked this conversation as resolved.
Show resolved Hide resolved
else:
for dist, exc in errors.items():
self.on_broken_distribution(dist, exc)
Expand Down
2 changes: 1 addition & 1 deletion envisage/egg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def add_eggs_on_path(working_set, path, on_error=None):
if on_error:
on_error(errors)
else:
raise SystemError("Cannot find eggs %s" % errors)
raise RuntimeError("Cannot find compatible eggs %s" % errors)
mdickinson marked this conversation as resolved.
Show resolved Hide resolved

# Add the distributions to the working set (this makes any Python
# modules in the eggs available for importing).
Expand Down
4 changes: 2 additions & 2 deletions envisage/i_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def start_plugin(self, plugin=None, plugin_id=None):
If a plugin is specified then start it.

If no plugin is specified then the Id is used to look up the plugin
and then start it. If no such plugin exists then a 'SystemError'
and then start it. If no such plugin exists then a 'ValueError'
exception is raised.

"""
Expand All @@ -82,7 +82,7 @@ def stop_plugin(self, plugin=None, plugin_id=None):
If a plugin is specified then stop it (the Id is ignored).

If no plugin is specified then the Id is used to look up the plugin and
then stop it. If no such plugin exists then a 'SystemError' exception
then stop it. If no such plugin exists then a 'ValueError' exception
is raised.

"""
4 changes: 2 additions & 2 deletions envisage/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def start_plugin(self, plugin=None, plugin_id=None):
logger.debug("plugin %s started", plugin.id)

else:
raise SystemError("no such plugin %s" % plugin_id)
raise ValueError("no such plugin %s" % plugin_id)

def stop(self):
""" Stop the plugin manager. """
Expand All @@ -166,7 +166,7 @@ def stop_plugin(self, plugin=None, plugin_id=None):
logger.debug("plugin %s stopped", plugin.id)

else:
raise SystemError("no such plugin %s" % plugin_id)
raise ValueError("no such plugin %s" % plugin_id)

#### Protected 'PluginManager' ############################################

Expand Down
2 changes: 1 addition & 1 deletion envisage/provider_extension_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ProviderExtensionRegistry(ExtensionRegistry):
def set_extensions(self, extension_point_id, extensions):
""" Set the extensions to an extension point. """

raise SystemError("extension points cannot be set")
raise RuntimeError("extension points cannot be set")
mdickinson marked this conversation as resolved.
Show resolved Hide resolved

###########################################################################
# 'ProviderExtensionRegistry' interface.
Expand Down
2 changes: 1 addition & 1 deletion envisage/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get(self, obj, trait_name):
def set(self, obj, name, value):
""" Trait type setter. """

raise SystemError("Service traits cannot be set")
raise RuntimeError("Service traits cannot be set")
mdickinson marked this conversation as resolved.
Show resolved Hide resolved

###########################################################################
# Private interface.
Expand Down
4 changes: 2 additions & 2 deletions envisage/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ def test_start_and_stop_errors(self):
application.stop()

# Try to start a non-existent plugin.
with self.assertRaises(SystemError):
with self.assertRaises(ValueError):
application.start_plugin(plugin_id="bogus")

# Try to stop a non-existent plugin.
with self.assertRaises(SystemError):
with self.assertRaises(ValueError):
application.stop_plugin(plugin_id="bogus")

def test_extension_point(self):
Expand Down
2 changes: 1 addition & 1 deletion envisage/tests/test_egg_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _add_eggs_on_path(self, path, working_set=None):
# Py2 tests was checking that len(errors) > 0. This did not work on
# Py3. Test changed to check the len(distributions)
if len(distributions) == 0:
raise SystemError("Cannot find eggs %s" % errors)
raise RuntimeError("Cannot find compatible eggs %s" % errors)
mdickinson marked this conversation as resolved.
Show resolved Hide resolved

# Add the distributions to the working set (this makes any Python
# modules in the eggs available for importing).
Expand Down
2 changes: 1 addition & 1 deletion envisage/tests/test_egg_basket_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_ignore_broken_distributions_raises_exceptions_by_default(self):
self._create_broken_distribution_eggdir("acme.foo*.egg"),
],
)
with self.assertRaises(SystemError):
with self.assertRaises(RuntimeError):
iter(plugin_manager)

def test_ignore_broken_distributions_loads_good_distributions(self):
Expand Down
2 changes: 1 addition & 1 deletion envisage/tests/test_extension_point_changed.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_set_extension_point(self):
application.start()

# Try to set the extension point.
with self.assertRaises(SystemError):
with self.assertRaises(RuntimeError):
setattr(a, "x", [1, 2, 3])

def test_mutate_extension_point_no_events(self):
Expand Down
4 changes: 2 additions & 2 deletions envisage/tests/test_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def test_start_and_stop_errors(self):
plugin_manager.stop()

# Try to start a non-existent plugin.
with self.assertRaises(SystemError):
with self.assertRaises(ValueError):
plugin_manager.start_plugin(plugin_id="bogus")

# Try to stop a non-existent plugin.
with self.assertRaises(SystemError):
with self.assertRaises(ValueError):
plugin_manager.stop_plugin(plugin_id="bogus")

def test_only_include_plugins_whose_ids_are_in_the_include_list(self):
Expand Down
2 changes: 1 addition & 1 deletion envisage/tests/test_provider_extension_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def test_set_extensions(self):
registry.add_extension_point(self.create_extension_point("my.ep"))

# Set some extensions.
with self.assertRaises(SystemError):
with self.assertRaises(RuntimeError):
registry.set_extensions("my.ep", [1, 2, 3])

def test_remove_non_empty_extension_point(self):
Expand Down
2 changes: 1 addition & 1 deletion envisage/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PluginB(Plugin):
self.assertEqual(None, b.foo)

# You can't set service traits!
with self.assertRaises(SystemError):
with self.assertRaises(RuntimeError):
setattr(b, "foo", "bogus")

def test_service_trait_type_with_no_service_registry(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/legacy/MOTD_Using_Eggs/dist/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def main():

distributions, errors = working_set.find_plugins(environment)
if len(errors) > 0:
raise SystemError('cannot add eggs %s' % errors)
raise RuntimeError('cannot add compatible eggs %s' % errors)
mdickinson marked this conversation as resolved.
Show resolved Hide resolved

logger.debug('added eggs %s' % distributions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create_control(self, parent):

method = getattr(self, "_%s_create_control" % ETSConfig.toolkit, None)
if method is None:
raise SystemError("Unknown toolkit %s", ETSConfig.toolkit)
raise RuntimeError("Unknown toolkit %s", ETSConfig.toolkit)

color = self.name.lower()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main():

distributions, errors = working_set.find_plugins(environment)
if len(errors) > 0:
raise SystemError('cannot add eggs %s' % errors)
raise RuntimeError('cannot add eggs %s' % errors)

logger.debug('added eggs %s' % distributions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create_control(self, parent):

method = getattr(self, "_%s_create_control" % ETSConfig.toolkit, None)
if method is None:
raise SystemError("Unknown toolkit %s", ETSConfig.toolkit)
raise RuntimeError("Unknown toolkit %s", ETSConfig.toolkit)

color = self.name.lower()

Expand Down