Here you can find the source of exceptionFormat(E exception)
public static <E> String exceptionFormat(E exception)
//package com.java2s; //License from project: Open Source License public class Main { public static <E> String exceptionFormat(E exception) { Exception e = (Exception) exception; Integer line = null;//from w w w. j av a 2s .c o m String className = null; String methodName = null; if (e.getStackTrace() != null && e.getStackTrace().length > 2) { line = e.getStackTrace()[2].getLineNumber(); className = e.getStackTrace()[2].getClassName(); methodName = e.getStackTrace()[2].getMethodName(); } if (line == null) { line = Thread.currentThread().getStackTrace()[2].getLineNumber(); } if (className == null) { className = Thread.currentThread().getStackTrace()[2].getClassName(); } if (methodName == null) { methodName = Thread.currentThread().getStackTrace()[2].getMethodName(); } return String.format("The msg: %s," + "The Class: %s," + "The Method: %s," + "The Line: %d,", e.getMessage(), className, methodName, line); } }