List of usage examples for java.lang Throwable getStackTrace
public StackTraceElement[] getStackTrace()
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); System.out.println(t.getStackTrace()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { try {/*from ww w. j av a 2 s. co m*/ int x = 1, y = 0; System.out.println(x / y); } catch (Throwable e) { StackTraceElement stack[] = e.getStackTrace(); for (int i = 0; i < stack.length; i++) { String filename = stack[i].getFileName(); if (filename == null) { System.out.println("filename is not available"); } String className = stack[i].getClassName(); System.out.println(className); String methodName = stack[i].getMethodName(); System.out.println(methodName); boolean isNativeMethod = stack[i].isNativeMethod(); System.out.println(isNativeMethod); int line = stack[i].getLineNumber(); System.out.println(line); } } }
From source file:de.speexx.csv.table.app.Application.java
public static void main(final String... args) { try {/*w ww . j av a2 s . co m*/ new Application().run(args); } catch (final Throwable t) { LOG.error("Unexpected end of application: {}", t.getMessage()); final StackTraceElement[] st = t.getStackTrace(); LOG.error("Location - class: {} - method: {} - line: {}", st[0].getClassName(), st[0].getMethodName(), st[0].getLineNumber()); System.exit(1); } System.exit(0); }
From source file:UnitTest4.java
public static void main(String args[]) { System.setProperty("org.slf4j.simpleLogger.showDateTime", "true"); System.setProperty("org.slf4j.simpleLogger.showThreadName", "true"); System.setProperty("org.slf4j.simpleLogger.levelInBrackets", "true"); System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd HH:mm:ss:SSS Z"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); System.setProperty("org.slf4j.simpleLogger.showLogName", "true"); final Logger log = LoggerFactory.getLogger(UnitTest4.class); UnitTest4.log = log;//from w w w .j av a 2 s . c o m System.out.println("hdfjkv \'dfdgdf\'dgdf"); try { throw new Exception(); } catch (Throwable e) { log.debug(e.toString()); //log.debug(" Cause : " + e.getCause().toString()); StackTraceElement stacka[] = e.getStackTrace(); for (StackTraceElement stack : stacka) { log.debug(" StackTrace : " + stack.toString()); } } String a[] = new String[10]; a[0] = "hwedf"; a[6] = "wdeeg"; log.debug("a.toString() : {}", a.toString()); /* List<Integer> list = new ArrayList<Integer>(); for (Integer i : list) { System.out.println(i); } System.out.println("ok"); try { //Test2.execute(); } catch (Exception e) { e.printStackTrace(); } */ }
From source file:nl.tudelft.goal.SimpleIDE.SimpleIDE.java
/** * main function to start the GOAL IDE/* w w w .j a va 2 s. c o m*/ */ public static void main(String[] args) { try { new SimpleIDE(); } catch (Throwable e) { JOptionPane.showMessageDialog(null, Resources.get(WarningStrings.FAILED_IDE_LAUNCH) + e.getMessage() + "\n" //$NON-NLS-1$ + e.getStackTrace()[0]); } }
From source file:Main.java
static public void saveCrashTrace(Throwable ex) { StackTraceElement[] elements = ex.getStackTrace(); StringBuilder builder = new StringBuilder(ex.getMessage()); for (StackTraceElement ele : elements) { builder.append('\n').append(ele.toString()); }/*from ww w.j a v a 2 s . c o m*/ android.util.Log.e("crash", builder.toString()); }
From source file:Main.java
public static void method_end() { Throwable t = new Throwable(); StackTraceElement e = t.getStackTrace()[2]; Log.d(e.getClassName(), e.getMethodName() + ": end"); }
From source file:Main.java
public static void method_start() { Throwable t = new Throwable(); StackTraceElement e = t.getStackTrace()[2]; Log.d(e.getClassName(), e.getMethodName() + ": start"); }
From source file:StackTraceTest.java
/** * Computes the factorial of a number/*from www. j av a2 s . c om*/ * @param n a nonnegative integer * @return n! = 1 * 2 * . . . * n */ public static int factorial(int n) { System.out.println("factorial(" + n + "):"); Throwable t = new Throwable(); StackTraceElement[] frames = t.getStackTrace(); for (StackTraceElement f : frames) System.out.println(f); int r; if (n <= 1) r = 1; else r = n * factorial(n - 1); System.out.println("return " + r); return r; }
From source file:Main.java
public static boolean isXposedExists(Throwable thr) { StackTraceElement[] stackTraces = thr.getStackTrace(); for (StackTraceElement stackTrace : stackTraces) { final String clazzName = stackTrace.getClassName(); if (clazzName != null && clazzName.contains("de.robv.android.xposed.XposedBridge")) { return true; }/*from w ww. j a v a2s .c om*/ } return false; }