Standardise "Failed to load results" errors!

This commit is contained in:
jesopo 2018-10-20 20:51:29 +01:00
parent 90c730979a
commit 8ea6db9422
19 changed files with 23 additions and 20 deletions

View file

@ -22,4 +22,4 @@ class Module(ModuleManager.BaseModule):
event["stderr"].write("Unknown currency, available " event["stderr"].write("Unknown currency, available "
"currencies: %s" % ", ".join(page.keys())) "currencies: %s" % ", ".join(page.keys()))
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -34,7 +34,7 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("Unable to find book") event["stderr"].write("Unable to find book")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
@utils.hook("received.command.isbn", min_args=1) @utils.hook("received.command.isbn", min_args=1)
def isbn(self, event): def isbn(self, event):

View file

@ -39,7 +39,7 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No definitions found") event["stderr"].write("No definitions found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
@utils.hook("received.command.randomword") @utils.hook("received.command.randomword")
def random_word(self, event): def random_word(self, event):
@ -63,6 +63,6 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("Random Word: %s - Definition: %s" % ( event["stdout"].write("Random Word: %s - Definition: %s" % (
page["word"], definition["text"])) page["word"], definition["text"]))
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
else: else:
event["stderr"].write("Try again in a couple of seconds") event["stderr"].write("Try again in a couple of seconds")

View file

@ -29,7 +29,7 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No results found") event["stderr"].write("No results found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
else: else:
event["stderr"].write("No phrase provided") event["stderr"].write("No phrase provided")
@ -56,6 +56,6 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No suggestions found") event["stderr"].write("No suggestions found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
else: else:
event["stderr"].write("No phrase provided") event["stderr"].write("No phrase provided")

View file

@ -23,4 +23,4 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("It seems '%s' has not been pwned" % ( event["stdout"].write("It seems '%s' has not been pwned" % (
event["args"])) event["args"]))
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -28,4 +28,4 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("Title not found") event["stderr"].write("Title not found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -52,7 +52,7 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No geoip data found") event["stderr"].write("No geoip data found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
@utils.hook("received.command.rdns") @utils.hook("received.command.rdns")
def rdns(self, event): def rdns(self, event):

View file

@ -84,4 +84,4 @@ class Module(ModuleManager.BaseModule):
"The user '%s' has never scrobbled before" % ( "The user '%s' has never scrobbled before" % (
shown_username)) shown_username))
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -59,4 +59,4 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("%s [%s] (posted by %s) %s" % (title, event["stdout"].write("%s [%s] (posted by %s) %s" % (title,
duration, user, link)) duration, user, link))
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -24,4 +24,4 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No results found") event["stderr"].write("No results found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -41,4 +41,4 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("Category not found") event["stderr"].write("Category not found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -54,4 +54,4 @@ class Module(ModuleManager.BaseModule):
event["stderr"].write( event["stderr"].write(
"%s is not watching anything" % username) "%s is not watching anything" % username)
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -47,4 +47,4 @@ class Module(ModuleManager.BaseModule):
", size: %s, price: %s)" % ( ", size: %s, price: %s)" % (
brand, title, description, weight, size, pricing)) brand, title, description, weight, size, pricing))
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -32,4 +32,4 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No results found") event["stderr"].write("No results found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -33,4 +33,4 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No weather information for this location") event["stderr"].write("No weather information for this location")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -25,5 +25,5 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No results found") event["stderr"].write("No results found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -25,4 +25,4 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stdout"].write("No results") event["stdout"].write("No results")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()

View file

@ -99,7 +99,7 @@ class Module(ModuleManager.BaseModule):
else: else:
event["stderr"].write("No videos found") event["stderr"].write("No videos found")
else: else:
event["stderr"].write("Failed to load results") raise utils.EventsResultsError()
if video_id: if video_id:
event["stdout"].write(self.video_details(video_id)) event["stdout"].write(self.video_details(video_id))
else: else:

View file

@ -136,6 +136,9 @@ def prevent_highlight(nickname):
class EventError(Exception): class EventError(Exception):
pass pass
class EventsResultsError(EventError):
def __init__(self):
EventError.__init__(self, "Failed to load results")
def _set_get_append(obj, setting, item): def _set_get_append(obj, setting, item):
if not hasattr(obj, setting): if not hasattr(obj, setting):