List of usage examples for java.lang Throwable getCause
public synchronized Throwable getCause()
From source file:com.aw.support.reflection.MethodInvoker.java
public static Object invoke(Object target, Object[] methodName, Object param) throws Throwable { List results = new ArrayList(); try {/* ww w .ja v a2s . c om*/ Class cls = target.getClass(); Class[] paramTypes = new Class[] { Object.class }; for (int i = 0; i < methodName.length; i++) { Method method = cls.getMethod((String) methodName[i], paramTypes); Object obj = method.invoke(target, param); if (obj != null) { results.add(obj); } } } catch (Throwable e) { if (e.getCause() instanceof AWException) { e.getCause().printStackTrace(); throw (AWException) e.getCause(); } e.printStackTrace(); throw e; } return results; }
From source file:com.aw.support.reflection.MethodInvoker.java
public static Object invoke(Object target, Object[] methodNames) throws Throwable { java.util.List results = new ArrayList(); try {// www. ja va 2 s. c o m Class cls = target.getClass(); for (int i = 0; i < methodNames.length; i++) { Method method = cls.getMethod((String) methodNames[i]); Object obj = method.invoke(target); if (obj != null) { results.add(obj); } } } catch (Throwable e) { if (e.getCause() instanceof AWException) { e.printStackTrace(); throw ((AWException) e.getCause()); } e.printStackTrace(); throw e; } return results; }
From source file:com.metadave.eql.EQLConsole.java
private static void processOutput(RuntimeContext runtimeCtx, PrintWriter out, boolean ansi) { List<Throwable> errors = runtimeCtx.getErrors(); for (Throwable t : errors) { ANSIBuffer buf = new ANSIBuffer(); buf.setAnsiEnabled(ansi);/*from w w w . j ava 2s. c o m*/ buf.red(t.getMessage()); if (t.getCause() != null) { buf.red(":" + t.getCause().getMessage()); } buf.append("\n"); System.out.print(buf.toString()); } // TODO //runtimeCtx.reset(); }
From source file:com.tc.management.JMXConnectorProxy.java
static boolean isConnectException(IOException ioe) { Throwable t = ioe; while (t != null) { if (t instanceof ConnectException) { return true; }/* www.j a v a 2s. c o m*/ t = t.getCause(); } return false; }
From source file:org.apache.asterix.api.http.server.ResultUtil.java
public static Throwable getRootCause(Throwable cause) { Throwable currentCause = cause; Throwable nextCause = cause.getCause(); while (nextCause != null && nextCause != currentCause) { currentCause = nextCause;//from w w w .j a va 2 s . co m nextCause = nextCause.getCause(); } return currentCause; }
From source file:com.basho.contact.ContactConsole.java
private static void processOutput(RuntimeContext runtimeCtx, PrintWriter out, boolean ansi) { List<Throwable> errors = runtimeCtx.getErrors(); for (Throwable t : errors) { ANSIBuffer buf = new ANSIBuffer(); buf.setAnsiEnabled(ansi);// w w w . j ava 2 s.c o m buf.red(t.getMessage()); if (t.getCause() != null) { buf.red(":" + t.getCause().getMessage()); } buf.append("\n"); System.out.print(buf.toString()); } runtimeCtx.reset(); }
From source file:com.aw.support.reflection.MethodInvoker.java
/** * @param target//from w w w . j a v a2 s. c om * @param methodName * @param parameter * @return * @throws Throwable */ public static Object invoke(Object target, String methodName, Object parameter) throws Throwable { Object result = null; try { Class cls = target.getClass(); Class[] paramTypes = new Class[] { Object.class }; Method method = cls.getMethod(methodName, paramTypes); result = method.invoke(target, new Object[] { parameter }); } catch (Throwable e) { Throwable cause = e.getCause(); if ((cause instanceof FlowBreakSilentlyException) || (cause instanceof AWException) || (cause instanceof DataIntegrityViolationException)) { throw cause; } e.printStackTrace(); throw e; } return result; }
From source file:com.aw.support.reflection.MethodInvoker.java
/** * @param target//from w w w. jav a2 s . c o m * @param methodName * @param parameter * @return * @throws Throwable */ public static Object invoke(Object target, String methodName, Object parameter, Class parameterType) throws Throwable { Object result = null; try { Class cls = target.getClass(); Class[] paramTypes = new Class[] { parameterType }; Method method = cls.getMethod(methodName, paramTypes); result = method.invoke(target, new Object[] { parameter }); } catch (Throwable e) { Throwable cause = e.getCause(); if ((cause instanceof FlowBreakSilentlyException) || (cause instanceof AWException) || (cause instanceof DataIntegrityViolationException)) { throw cause; } e.printStackTrace(); throw e; } return result; }
From source file:com.alibaba.wasp.util.JVMClusterUtil.java
/** * Creates a {@link MasterThread}.// w ww. ja va2 s .c o m * Call 'start' on the returned thread to make it run. * @param c Configuration to use. * @param hmc Class to create. * @param index Used distinguishing the object returned. * @throws java.io.IOException * @return Master added. */ public static JVMClusterUtil.MasterThread createMasterThread(final Configuration c, final Class<? extends FMaster> hmc, final int index) throws IOException { FMaster server; try { server = hmc.getConstructor(Configuration.class).newInstance(c); } catch (InvocationTargetException ite) { Throwable target = ite.getTargetException(); throw new RuntimeException("Failed construction of Master: " + hmc.toString() + ((target.getCause() != null) ? target.getCause().getMessage() : ""), target); } catch (Exception e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } return new JVMClusterUtil.MasterThread(server, index); }
From source file:com.alibaba.wasp.util.JVMClusterUtil.java
/** * Creates a {@link FServerThread}.// w w w . j a va2s . c o m * Call 'start' on the returned thread to make it run. * @param c Configuration to use. * @param hrsc Class to create. * @param index Used distinguishing the object returned. * @throws java.io.IOException * @return FServer added. */ public static JVMClusterUtil.FServerThread createFServerThread(final Configuration c, final Class<? extends FServer> hrsc, final int index) throws IOException { FServer server; try { Constructor<? extends FServer> ctor = hrsc.getConstructor(Configuration.class); ctor.setAccessible(true); server = ctor.newInstance(c); } catch (InvocationTargetException ite) { Throwable target = ite.getTargetException(); throw new RuntimeException("Failed construction of FServer: " + hrsc.toString() + ((target.getCause() != null) ? target.getCause().getMessage() : ""), target); } catch (Exception e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } return new JVMClusterUtil.FServerThread(server, index); }