]> git.ipfire.org Git - location/location-database.git/blobdiff - tools/base.py
tools: Handle any error messages inlined into the response
[location/location-database.git] / 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