]> git.ipfire.org Git - location/location-database.git/commitdiff
tools: Handle any error messages inlined into the response
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2020 16:25:42 +0000 (16:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2020 16:25:42 +0000 (16:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tools/base.py

index 0b8a068c8bb270ac902685f753d50e078eeed8ef..04f0016b0f8047906fc7b2bc9dd616032bbaf9fb 100644 (file)
@@ -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