-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkClientV3.java
More file actions
42 lines (35 loc) · 1.15 KB
/
Copy pathNetworkClientV3.java
File metadata and controls
42 lines (35 loc) · 1.15 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
40
41
42
package exception.ex3;
import exception.ex3.NetworkClientExceptionV3
;
public class NetworkClientV3 {
private final String address;
public boolean connectError;
public boolean sendError;
public NetworkClientV3(String address) {
this.address = address;
}
public void connect() throws ConnectExceptionV3 {
if(connectError){
throw new ConnectExceptionV3(address, address + "서버 연결 실패");
}
System.out.println(address + " 서버 연결 성공 ");
}
public void send(String data) throws SendExceptionV3 {
if(sendError){
throw new SendExceptionV3(data, 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;
}
}
}