From 773d11f6cbaa8da91185547b0ab67f3706d735c2 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 16 Oct 2018 15:09:58 +0100 Subject: Change all instances of stdout.write+return to `raise utils.EventError` in modules --- modules/todo.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'modules/todo.py') diff --git a/modules/todo.py b/modules/todo.py index ac8293b8..1300cd36 100644 --- a/modules/todo.py +++ b/modules/todo.py @@ -31,9 +31,7 @@ class Module(ModuleManager.BaseModule): todo = event["user"].get_setting("todo", []) for item in todo: if item.lower() == arg_lower: - event["stderr"].write( - "That is already in your todo") - return + raise utils.EventError("That is already in your todo") todo.append(event["args"]) event["user"].set_setting("todo", todo) event["stdout"].write("Saved") @@ -70,14 +68,12 @@ class Module(ModuleManager.BaseModule): _from, to = int(_from_str)-1, int(to_str)-1 if _from < 0 or to < 0: - event["stderr"].write("Both indexes must be above 0") - return + raise utils.EventError("Both indexes must be above 0") todo = event["user"].get_setting("todo", []) if _from > len(todo) or to > len(todo): - event["stderr"].write("Both indexes must be less than the " + raise utils.EventError("Both indexes must be less than the " "size of your todo list") - return todo.insert(to, todo.pop(_from)) event["user"].set_setting("todo", todo) -- cgit v1.3.1-10-gc9f91