Use voussoirkit.httperrors.

master
voussoir 2021-11-13 01:20:26 -08:00
parent e8a0b0a050
commit 1bbb8bedee
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 2 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import requests
import socket
import time
from voussoirkit import httperrors
from voussoirkit import vlogging
log = vlogging.getLogger(__name__, 'networktools')
@ -26,7 +27,7 @@ class NoInternet(NetworkToolsException):
def get_external_ip(timeout=10) -> str:
url = 'https://voussoir.net/whatsmyip'
response = requests.get(url, timeout=timeout)
response.raise_for_status()
httperrors.raise_for_status(response)
ip = response.text.strip()
return ip