List of usage examples for java.lang Exception Exception
public Exception()
From source file:Main.java
public static String getFileLineMethod() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[1]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getFileName()).append(" | ") .append(traceElement.getLineNumber()).append(" | ").append(traceElement.getMethodName()) .append("()").append("]"); return toStringBuffer.toString(); }
From source file:Main.java
/** Creates an prints a stack trace */ public static void printStackTrace() { Exception e = new Exception(); e.fillInStackTrace();//www .ja v a2 s . c o m e.printStackTrace(); }
From source file:Main.java
/** * Get the class name of the direct class calling this method. *///from w w w . j av a 2 s. co m public static final String getDirectCallingClass() { return new Exception().getStackTrace()[1].getClassName(); }
From source file:Main.java
/** * Get the simple name of the direct class calling this method. *///ww w.j a v a2 s. co m public static final String getDirectCallingClassSimpleName() { final String className = new Exception().getStackTrace()[1].getClassName(); return className.substring(className.lastIndexOf(".") + 1); }
From source file:Main.java
/** * Get the class name of the indirect class calling this method - the class calling the class * calling this method/* w w w. jav a 2s .c o m*/ */ public static final String getIndirectCallingClass() { return new Exception().getStackTrace()[2].getClassName(); }
From source file:Main.java
/** * Get the simple name of the indirect class calling this method - the class calling the class * calling this method//from w ww . j a v a 2 s.c o m */ public static final String getIndirectCallingClassSimpleName() { final String className = new Exception().getStackTrace()[2].getClassName(); return className.substring(className.lastIndexOf(".") + 1); }
From source file:Main.java
public static void openFeedback(Activity activity) { try {/*from ww w . j a v a 2 s. c o m*/ throw new Exception(); } catch (Exception e) { ApplicationErrorReport report = new ApplicationErrorReport(); report.packageName = report.processName = activity.getApplication().getPackageName(); report.time = System.currentTimeMillis(); report.type = ApplicationErrorReport.TYPE_CRASH; report.systemApp = false; ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo(); crash.exceptionClassName = e.getClass().getSimpleName(); crash.exceptionMessage = e.getMessage(); StringWriter writer = new StringWriter(); PrintWriter printer = new PrintWriter(writer); e.printStackTrace(printer); crash.stackTrace = writer.toString(); StackTraceElement stack = e.getStackTrace()[0]; crash.throwClassName = stack.getClassName(); crash.throwFileName = stack.getFileName(); crash.throwLineNumber = stack.getLineNumber(); crash.throwMethodName = stack.getMethodName(); report.crashInfo = crash; Intent intent = new Intent(Intent.ACTION_APP_ERROR); intent.putExtra(Intent.EXTRA_BUG_REPORT, report); activity.startActivity(intent); } }
From source file:Main.java
public static String getCompressedStackTrace() { try {// w ww. ja v a 2 s. com throw new Exception(); } catch (Exception e) { return getCompressedStackTrace(e, 1, 12); } }
From source file:Main.java
public static Date parseDate(String date, String[] dateParttens) throws Exception { SimpleDateFormat df = null;/*from www . ja va2s .c om*/ Date d = null; boolean isParse = false; for (String partten : dateParttens) { df = new SimpleDateFormat(partten); try { d = df.parse(date); isParse = true; break; } catch (ParseException e) { isParse = false; } } if (!isParse) { throw new Exception(); } return d; }
From source file:Main.java
public static String getCompressedStackTrace(int limit) { try {/* ww w . j a va2 s. co m*/ throw new Exception(); } catch (Exception e) { return getCompressedStackTrace(e, 1, limit); } }