01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.exception;
05:
06: import org.mortbay.util.MultiException;
07:
08: /**
09: * Deal with Jetty MultiException to extract useful info
10: */
11: public class MortbayMultiExceptionHelper implements ExceptionHelper {
12:
13: /**
14: * Accepts only the Jetty MultiException
15: * @param t Throwable
16: * @return True if Jetty MultiException
17: */
18: public boolean accepts(Throwable t) {
19: return t instanceof MultiException;
20: }
21:
22: /**
23: * Get closest cause, which is defined here as the first exception
24: * in a MultiException.
25: * @param t MultiException
26: * @return First in the MultiException
27: */
28: public Throwable getProximateCause(Throwable t) {
29: if (t instanceof MultiException) {
30: MultiException m = (MultiException) t;
31: if (m.size() > 0)
32: return m.getThrowable(0);
33: }
34: return t;
35: }
36:
37: /**
38: * No ultimate exception retrieved - always throws AssertionError
39: * @param t Param ignored
40: * @return Always AssertionError
41: */
42: public Throwable getUltimateCause(Throwable t) {
43: throw new AssertionError();
44: }
45:
46: }
|