-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkClientV2.java
More file actions
39 lines (33 loc) · 1.13 KB
/
Copy pathNetworkClientV2.java
File metadata and controls
39 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package exception.ex2;
public class NetworkClientV2 {
private final String address;
public boolean connectError;
public boolean sendError;
public NetworkClientV2(String address) {
this.address = address;
}
public void connect() throws NetworkClientExceptionV2 {
if(connectError){
throw new NetworkClientExceptionV2("connectError", address + "서버 연결 실패");
}
System.out.println(address + " 서버 연결 성공 ");
}
public void send(String data) throws NetworkClientExceptionV2 {
if(sendError){
throw new NetworkClientExceptionV2("sendError", address + "서버에 데이터 전송 실패 : " + data);
// throw new RuntimeException("ex");
}
System.out.println(address + " 서버에 데이터 전송 : " + data);
}
public void disconnect(){
System.out.println(address + " 서버 연결 해제");
}
public void initError(String data){
if(data.contains("error1")){
connectError = true;
}
if(data.contains("error2")){
sendError = true;
}
}
}