List of usage examples for java.lang Throwable toString
public String toString()
From source file:com.norbl.util.StringUtil.java
private static String throwableToString(Throwable x, String prefix) { String mess = x.toString() + "\n\n" + stackTraceToString(x.getStackTrace()); Throwable cause = x.getCause(); if (cause != null) { mess += "\nCAUSE:\n" + throwableToString(cause, prefix + " "); }//from w ww .j a v a 2 s . c o m return (mess); }
From source file:com.yahoo.elide.core.exceptions.HttpStatusException.java
protected static String formatExceptionCause(Throwable e) { // if the throwable has a cause use that, otherwise the throwable is the cause Throwable error = e.getCause() == null ? e : e.getCause(); return error == null ? null : error.getMessage() == null ? error.toString() : error.getMessage(); }
From source file:com.kappaware.logtrawler.Utils.java
public static String toString(Throwable e) { StringBuffer sb = new StringBuffer(); sb.append(e.toString()); while ((e = e.getCause()) != null) { sb.append("\nCaused by:"); sb.append(e.toString());// ww w. j a v a 2s . c o m } ; return sb.toString(); }
From source file:ratpack.sep.ActionResult.java
/** * Creates an error result, with the given exception. * <p>/*from www . j av a 2 s. c o m*/ * The message of the given exception will be used as the message of the result * @param error an exception thrown during action exception * @param <T> a type of accompanying data * @return an failed result, with the given error */ public static <T> ActionResult<T> error(Throwable error) { return new ActionResult<>(error.toString(), error.getMessage(), error, null); }
From source file:com.googlecode.android_scripting.jsonrpc.JsonRpcResult.java
public static JSONObject error(int id, Throwable t) throws JSONException { JSONObject json = new JSONObject(); json.put("id", id); json.put("result", JSONObject.NULL); json.put("error", t.toString()); return json;/*from www.j a va 2s. co m*/ }
From source file:Main.java
public static String getStackTrace(Throwable t) { String CRLF = System.getProperty("line.separator"); StringBuffer sb = new StringBuffer(); sb.append(t.toString() + CRLF); StackTraceElement[] se = t.getStackTrace(); if (se != null) { for (int i = 0; i < se.length; i++) { if (se[i] != null) { sb.append("\t" + se[i].toString()); if (i != se.length - 1) { sb.append(CRLF);//from www . ja va 2s. c om } } } } return sb.toString(); }
From source file:com.freemedforms.openreact.db.DbSchema.java
/** * Attempt to run a database patch./*from www .java 2s.c o m*/ * * @param patchFilename * @return Success. * @throws SQLException */ public static boolean applyPatch(String patchFilename) throws SQLException { Connection c = Configuration.getConnection(); String patch = null; Scanner scanner; try { scanner = new Scanner(new File(patchFilename)).useDelimiter("\\Z"); patch = scanner.next(); scanner.close(); } catch (FileNotFoundException ex) { log.error(ex); return false; } Statement cStmt = c.createStatement(); boolean status = false; try { log.debug("Using patch length = " + patch.length()); cStmt.execute(patch); // cStmt = c.prepareStatement(patch); // cStmt.execute(); log.info("Patch succeeded"); status = true; } catch (NullPointerException npe) { log.error("Caught NullPointerException", npe); } catch (Throwable e) { log.error(e.toString()); } finally { DbUtil.closeSafely(cStmt); DbUtil.closeSafely(c); } return status; }
From source file:de.micromata.genome.gwiki.utils.ClassUtils.java
@SuppressWarnings("unchecked") public static <T> T createDefaultInstance(String className, Class<? extends T> classExpected) { try {//w w w. j av a 2 s.co m Class<? extends T> ret = (Class<? extends T>) Class.forName(className, true, Thread.currentThread().getContextClassLoader()); return ret.newInstance(); } catch (Throwable ex) { throw new RuntimeException("Cannot create class instance: " + ex.toString(), ex); } }
From source file:de.micromata.genome.gwiki.utils.ClassUtils.java
public static <T> T createDefaultInstance(Class<? extends T> cls) { try {//from w w w . j av a 2s .c o m return cls.newInstance(); } catch (Throwable ex) { throw new RuntimeException("Cannot Instantiate class instance: " + ex.toString(), ex); } }
From source file:org.LexGrid.LexBIG.caCore.client.proxy.LexEVSApplicationServiceProxy.java
private static boolean isLexBigException(Throwable th) { if (th.toString().indexOf("org.LexGrid.LexBIG.Exceptions") != -1) { return true; } else {// ww w . j a v a 2 s . c o m return false; } }