summaryrefslogtreecommitdiff
path: root/java/12-error-handling-2/MathsTest.java
blob: 7b6827cdc227eef579f8f80ab9e5c61918686f6c (plain)
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
public class MathsTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Maths m = new Maths();
		int result = 0;
		
		try {
			m.factorial(-5);
			m.factorial(5); // Not executed
		} catch (MathsException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
		    result = m.factorial(-5);
		    // ...
		} catch(MathsException me) {
//			System.err.println(me.getX());
			System.err.println("Factorial method failed");
		} finally {
			System.out.println("Inside finally block");
		}
		
		System.out.println(result);
		
	}

}