From 7bd3ef22b9ee92c44db88b82842ce7566bb54246 Mon Sep 17 00:00:00 2001 From: Georg Date: Mon, 24 Jan 2022 04:36:23 +0000 Subject: [PATCH] Reduce unhandled shortening exceptions (#35) Signed-off-by: Georg Pfuetzenreuter --- pbincli/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pbincli/api.py b/pbincli/api.py index 8ea32a2..f526d3a 100644 --- a/pbincli/api.py +++ b/pbincli/api.py @@ -89,6 +89,9 @@ class Shortener: def __init__(self, settings=None): self.api = settings['short_api'] + if self.api is None: + PBinCLIError("Unable to activate link shortener without short_api.") + # we checking which service is used, because some services doesn't require # any authentication, or have only one domain on which it working if self.api == 'yourls': @@ -256,6 +259,9 @@ class Shortener: def _custom(self, url): + if self.apiurl is None: + PBinCLIError("No short_url specified - link will not be shortened.") + from urllib.parse import quote qUrl = quote(url, safe="") # urlencoded paste url rUrl = self.apiurl.replace("{{url}}", qUrl)