Add the error if the client could not connect to the server.
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import struct
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
from notification_client.MessagePrinter import MessagePrinter
|
from notification_client.MessagePrinter import MessagePrinter
|
||||||
from notification_client.notitication import Notification
|
from notification_client.notitication import Notification
|
||||||
|
|
||||||
@@ -31,7 +33,12 @@ class Client:
|
|||||||
self.__port = port
|
self.__port = port
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
reader, writer = await asyncio.open_connection(self.__ip, self.__port)
|
try:
|
||||||
|
reader, writer = await asyncio.open_connection(self.__ip, self.__port)
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
sys.stderr.write("Could not connect to the server. Please, check the ip and the port.\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
await self.handle(reader, writer)
|
await self.handle(reader, writer)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user