From: Michael Tremer Date: Thu, 6 Feb 2020 16:25:42 +0000 (+0000) Subject: tools: Handle any error messages inlined into the response X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24eca81bb05271c69406509ebd72e66b9f6caa55;p=location%2Flocation-database.git tools: Handle any error messages inlined into the response Signed-off-by: Michael Tremer --- diff --git a/tools/base.py b/tools/base.py index 0b8a068..04f0016 100644 --- a/tools/base.py +++ b/tools/base.py @@ -116,7 +116,15 @@ class RIR(object): logging.error("Could not run WHOIS query %s: %s" % (query, e.output)) raise - return output.decode(errors="ignore") + # Decode output + output = output.decode(errors="ignore") + + # Scan for any errors + for line in output.splitlines(): + if line.startswith("%ERROR:"): + raise OSError(output) + + return output def whois(self, query): # Try fetching a response from the cache