handle socket.error
This commit is contained in:
parent
f05a35dd96
commit
fd7253ded7
|
@ -61,6 +61,7 @@ pack_port = lambda i: struct.pack('>H', i)
|
|||
|
||||
def mcping_modern(host, port):
|
||||
""" pings a server using the modern (1.7+) protocol and returns data """
|
||||
try:
|
||||
# connect to the server
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
|
@ -89,6 +90,8 @@ def mcping_modern(host, port):
|
|||
|
||||
# Close our socket
|
||||
s.close()
|
||||
except socket.error:
|
||||
raise PingError("Socket Error")
|
||||
|
||||
# Load json and return
|
||||
data = json.loads(d.decode('utf8'))
|
||||
|
|
Reference in a new issue