-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGL_TestException.java
More file actions
39 lines (34 loc) · 965 Bytes
/
GL_TestException.java
File metadata and controls
39 lines (34 loc) · 965 Bytes
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
public class Main {
public static void main(String[] args) {
try {
throw new Exception("Something is going wrong. Please contact system administrator.");
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println(e.getCause());
} finally {
System.out.println("Finally block has been executed.");
}
MyTest myTest = new MyTest();
try {
myTest.Test();
} catch (MyException e) {
e.printMessage();
}
}
}
public class MyException extends Exception {
private String message;
public MyException(String message) {
this.message = message;
}
public void printMessage()
{
System.out.println(this.message);
}
}
public class MyTest {
public void Test() throws MyException{
throw new MyException("Exception message");
}
}