-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomException.java
More file actions
58 lines (48 loc) · 1.09 KB
/
Copy pathCustomException.java
File metadata and controls
58 lines (48 loc) · 1.09 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package dummy;
public class CustomException {
public CustomException() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
chk();
} catch(exc e) {
System.out.println(e.getMessage());
System.out.println( e.getMsg());
System.out.println( e.getCode());
System.out.println(1);
e.printStackTrace();;
} catch(Exception e) {
System.out.println(e.getMessage());
System.out.println(((exc) e).getMsg());
System.out.println(((exc) e).getCode());
e.printStackTrace();
}
}
public static void chk() throws exc {
if(1>0)
throw new exc("101", "MY EXCEPTION");
}
}
class exc extends Exception {
String code;
String msg;
public exc(String code, String msg) {
super(msg+" "+code);
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}