aboutsummaryrefslogtreecommitdiff
path: root/modules/upc.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-16 15:09:58 +0100
committerGravatar jesopo2018-10-16 15:09:58 +0100
commit773d11f6cbaa8da91185547b0ab67f3706d735c2 (patch)
treec46eb6709985ef7cdfb5bfe9b035fdbdedc4f91f /modules/upc.py
parentOnly log exceptions when they're not unsafe (diff)
signature
Change all instances of stdout.write+return to `raise utils.EventError` in
modules
Diffstat (limited to 'modules/upc.py')
-rw-r--r--modules/upc.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/upc.py b/modules/upc.py
index 7cbcbde4..f67f06b9 100644
--- a/modules/upc.py
+++ b/modules/upc.py
@@ -13,16 +13,14 @@ class Module(ModuleManager.BaseModule):
"""
arg_len = len(event["args_split"][0])
if not arg_len == 12 and not arg_len == 13:
- event["stderr"].write("Invalid UPC/EAN/GTIN provided")
- return
+ raise utils.EventError("Invalid UPC/EAN/GTIN provided")
page = utils.http.get_url(UPCITEMDB_URL,
get_params={"upc": event["args_split"][0]},
json=True)
if page:
if not len(page["items"]):
- event["stderr"].write("UPC/EAN not found")
- return
+ raise utils.EventError("UPC/EAN not found")
item = page["items"][0]
brand = item.get("brand", None)