View Javadoc
1   package psl;
2   
3   import ensure.Ensure;
4   
5   /**
6    * Default implementation of an exception handler.
7    */
8   public class DefaultExceptionHandler implements ExceptionHandler {
9   	/**
10  	 * Creates a new default exception handler.
11  	 */
12  	public DefaultExceptionHandler() {
13  		/*
14  		 * Nothing to do.
15  		 */
16  	}
17  	
18  	@Override
19  	public void thrown(DispatcherOp<?> op, Object subscriber, Throwable t,
20  			Thread dt) {
21  		Ensure.not_null(op, "op == null");
22  		Ensure.not_null(subscriber, "subscriber == null");
23  		Ensure.not_null(t, "t == null");
24  		Ensure.not_null(dt, "dt == null");
25  		
26  		/*
27  		 * PMD complains about printing the stack trace but that is
28  		 * exactly what we should be doing here.
29  		 */
30  		t.printStackTrace(); 
31  	}
32  	
33  	@Override
34  	public void thrown(Runnable task, Throwable t, Thread dt) {
35  		Ensure.not_null(task, "task == null");
36  		Ensure.not_null(t, "t == null");
37  		Ensure.not_null(dt, "dt == null");
38  		
39  		/*
40  		 * PMD complains about printing the stack trace but that is
41  		 * exactly what we should be doing here.
42  		 */
43  		t.printStackTrace(); 
44  	}
45  	
46  	@Override
47  	public void thrown(Throwable t) {
48  		Ensure.not_null(t, "t == null");
49  		
50  		/*
51  		 * PMD complains about printing the stack trace but that is
52  		 * exactly what we should be doing here.
53  		 */
54  		t.printStackTrace(); 
55  	}
56  }