List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:com.antsdb.saltedfish.util.UberUtil.java
public static Logger getThisLogger() { Exception x = new Exception(); StackTraceElement[] stack = x.getStackTrace(); String className = ""; if (stack != null) { if (stack.length >= 2) { className = stack[1].getClassName(); }//from w w w . j a v a 2 s .c o m } return LoggerFactory.getLogger(className); }
From source file:com.antsdb.saltedfish.util.UberUtil.java
public static Class<?> getThisClass() { try {//w w w . ja v a2 s . co m String className = ""; Exception x = new Exception(); StackTraceElement[] stack = x.getStackTrace(); if (stack != null) { if (stack.length >= 2) { className = stack[1].getClassName(); } } return Class.forName(className); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
From source file:com.infinities.skyport.timeout.ServiceProviderTimeLimiter.java
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception { Throwable cause = e.getCause(); if (cause == null) { throw e;//from w ww . j ava 2 s .c om } if (combineStackTraces) { StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class); cause.setStackTrace(combined); } if (cause instanceof Exception) { throw (Exception) cause; } if (cause instanceof Error) { throw (Error) cause; } // The cause is a weird kind of Throwable, so throw the outer exception. throw e; }
From source file:odin.gateway.ReportAllocation.java
private static void process(OdinResponse res) { logger.info("process"); StringBuffer msg = new StringBuffer(); msg.append("<p>ReportAllocation Completed."); List<Sprint> activeSprints = Sprint.getActiveSprints(); List<Individual> activeIndividuals = null; for (Sprint sprint : activeSprints) { activeIndividuals = Sprint.getActiveParticipantsNotContactedToday(sprint.getSprintName()); msg.append(" Processed the following individuals for sprint: " + sprint.getSprintName() + "<ul>"); for (Individual i : activeIndividuals) { try { processIndividual(i.getUserID(), sprint.getSprintName(), i.getEmailAddress(), i.getFirstName(), i.getManagerEmailAddress(), false); } catch (Exception e) { msg.append("<li>GOT ERROR WHEN ATTEMPTING TO PROCESS THE FOLLOWING RECORD: " + i.getFirstName() + " " + i.getLastName() + ", user=" + i.getUserID() + ", email=" + i.getEmailAddress()); msg.append("<br>-----> " + e.getStackTrace() + "</li>"); res.setStatusCode(-1);//w w w. j a va 2 s . c om res.setReasonPhrase(e.getMessage()); logger.error("failed", e); } msg.append("<li>" + i.getFirstName() + " " + i.getLastName() + ", user=" + i.getUserID() + ", email=" + i.getEmailAddress() + "</li>"); } msg.append("</ul>"); } res.setStatusCode(0); res.setReasonPhrase("OK"); res.setMessageBody(msg.toString()); }
From source file:com.bahmanm.karun.Utils.java
/** * Pops up a dialog containing useful information from exception such as * stack trace.//from w w w . jav a 2 s.c o m * * @param parent Parent component * @param ex Exception */ public static void showExceptionDialog(Frame parent, Exception ex) { String topic = ""; if (ex instanceof IOException) topic = "An I/O error occured."; else topic = "An error occured."; topic += " [" + ex.getClass().getName() + "]"; if (ex.getMessage() != null) topic += "\n" + ex.getMessage(); StackTraceElement[] stackTrace = ex.getStackTrace(); String stacktraceStr = ""; for (int i = 0; i < stackTrace.length; i++) stacktraceStr += stackTrace[i] + "\n"; ExceptionDialog edialog = new ExceptionDialog(parent, true, topic, stacktraceStr); edialog.setVisible(true); }
From source file:io.agi.framework.persistence.PersistenceUtil.java
/** * Import a subtree of entities and data. * * @param jsonEntities//from www . j ava 2s . c om * @param jsonData * @return */ public static boolean ImportSubtree(String jsonEntities, String jsonData) { try { PersistenceUtil.ImportEntities(jsonEntities); DataRefUtil.ImportData(jsonData); return true; } catch (Exception e) { _logger.error(e.getStackTrace()); return false; } }
From source file:library.artaris.cn.library.utils.SystemUtils.java
/** * ????/* w w w. j av a 2 s . co m*/ * @param context * @return */ public static int gc(Context context) { //long i = getDeviceUsableMemory(context); int count = 0; ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> serviceList = am.getRunningServices(100); if (serviceList != null) for (RunningServiceInfo service : serviceList) { if (service.pid == android.os.Process.myPid()) continue; try { android.os.Process.killProcess(service.pid); count++; } catch (Exception e) { e.getStackTrace(); continue; } } List<RunningAppProcessInfo> processList = am.getRunningAppProcesses(); if (processList != null) for (RunningAppProcessInfo process : processList) { if (process.importance > RunningAppProcessInfo.IMPORTANCE_VISIBLE) { String[] pkgList = process.pkgList; for (String pkgName : pkgList) { try { am.killBackgroundProcesses(pkgName); count++; } catch (Exception e) { e.getStackTrace(); continue; } } } } return count; }
From source file:io.agi.framework.persistence.PersistenceUtil.java
public static void LoadConfigs(String file) { Gson gson = new Gson(); try {//from w w w . ja v a2 s .c o m String jsonEntity = FileUtil.readFile(file); Type listType = new TypeToken<List<ModelEntityConfigPath>>() { }.getType(); List<ModelEntityConfigPath> modelConfigs = gson.fromJson(jsonEntity, listType); for (ModelEntityConfigPath modelConfig : modelConfigs) { _logger.debug("Persisting entity: " + modelConfig.entityName + " config path: " + modelConfig.configPath + " value: " + modelConfig.configValue); PersistenceUtil.SetConfig(modelConfig.entityName, modelConfig.configPath, modelConfig.configValue); } } catch (Exception e) { _logger.error(e.getStackTrace()); System.exit(-1); } }
From source file:com.redhat.rhn.testing.TestUtils.java
/** * Print the first few lines from a stacktrace so we can figure out who the caller * is. This is similiar to doing a Thread.dumpStack() but it just doesn't spit out * as many lines of the stacktrace.//from w w w. j a va 2 s . com * * @param depth the number of lines of the stacktrace you want to see */ public static void printWhoCalledMe(int depth) { StackTraceElement[] elements = null; try { throw new Exception("Nothing to see here"); } catch (Exception e) { elements = e.getStackTrace(); } // Only show 10 lines of the trace for (int i = 0; ((i < elements.length) && i < depth); i++) { System.out.println("Stack: [" + i + "]: " + elements[i].getClassName() + "." + elements[i].getMethodName() + " : " + elements[i].getLineNumber()); } }
From source file:br.com.nordestefomento.jrimum.utilix.Field.java
private static Exception getGenericReadError(Exception e, String value) { StackTraceElement[] stackTrace = e.getStackTrace(); e = new RuntimeException("VALOR INV?LIDO [ " + value + " ]!\nCausado por: " + e.getCause()); e.setStackTrace(stackTrace);//from ww w . j a v a 2s. co m return e; }