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