Java examples for java.lang:Exception
find Method from Throwable
//package com.java2s; public class Main { /**//from w w w. j a va 2 s. c o m * @param t Throwable * @return String */ public static String findMethod(Throwable t) { StackTraceElement ste = getStackTraceElement(t); return ste != null ? ste.getMethodName() : "none"; } /** * @param t Throwable * @return StackTraceElement */ public static StackTraceElement getStackTraceElement(Throwable t) { for (StackTraceElement ste : t.getStackTrace()) { if (!ste.isNativeMethod()) { return ste; } } return null; } }