From 57fb9a95515f3b605606eb161fabc7771e27c7c6 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: May 10 2019 11:35:51 +0000 Subject: [PATCH 1/2] No need to initialize 'output' to None --- diff --git a/libpagure/libpagure.py b/libpagure/libpagure.py index 0535ea6..1136759 100644 --- a/libpagure/libpagure.py +++ b/libpagure/libpagure.py @@ -88,7 +88,6 @@ class Pagure(object): verify=not self.insecure, ) - output = None try: output = req.json() except Exception as err: From 9d3a969a7460ed7eaf90eebd38f4d54bb3c08e66 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: May 10 2019 11:55:48 +0000 Subject: [PATCH 2/2] [_call_api] Use concise exception message when wrong url Otherwise one gets 'Error while decoding JSON', which is really confusing. --- diff --git a/libpagure/libpagure.py b/libpagure/libpagure.py index 1136759..da83f18 100644 --- a/libpagure/libpagure.py +++ b/libpagure/libpagure.py @@ -88,6 +88,10 @@ class Pagure(object): verify=not self.insecure, ) + if req.status_code == 404: + # TODO: use a dedicated error class + raise Exception("404, {} not found".format(url)) + try: output = req.json() except Exception as err: