From 78f9f22a4081615c0ab3f55f692bbf6aa3da6cd9 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 24 Mar 2010 22:52:03 -0700 Subject: [PATCH] Raise a KeyError exception if trying to stop a component that hasn't isn't registered --- deluge/component.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deluge/component.py b/deluge/component.py index 2b12de548..c5c38fb33 100644 --- a/deluge/component.py +++ b/deluge/component.py @@ -252,11 +252,20 @@ class ComponentRegistry(object): sucessfully stopped :rtype: twisted.internet.defer.Deferred + :raises KeyError: if a component name is not registered + """ if not names: names = self.components.keys() elif isinstance(names, str): - names = [names] + if names in self.components: + names = [names] + else: + raise KeyError("%s is not a registered component!" % names) + + for name in names: + if name is not in self.components: + raise KeyError("%s is not a registered component!" % name) deferreds = []