When opening an URL, an error may be raised and the wrong, not defined variable was logged.
Create an HTTPError or an URLError (socket.timeout), when opening "https://ipapi.co/json"
Nice catch. To be fair, there's a lot of url and error variables thrown around that aren't the same and this makes the code really unreadable and unmaintainable. If you wanted to go ahead and fix that, using, e.g. httperror instead of error for the HTTPError exception, that would be an added plus.