List of usage examples for java.lang StackTraceElement toString
public String toString()
From source file:org.gitana.platform.client.job.JobLogEntry.java
public void setStackTrace(StackTraceElement[] elements) { ArrayNode array = JsonUtil.createArray(); for (StackTraceElement element : elements) { array.add(element.toString()); }/*w ww. j a v a2 s .c om*/ set(FIELD_STACKTRACE, array); }
From source file:com.mtomczak.nausicaa.StatusView.java
@Override public void update(JSONObject telemetry) { String out = ""; try {/* w ww. j a v a 2 s. c om*/ String bodyName = telemetry.getString("v.body"); out += "[" + bodyName + "]"; if (telemetry.getBoolean(TIME_WARP_KEY)) { out += " [T]"; } out += "\n"; out += "Altitude: " + formatDouble(telemetry.getDouble("v.altitude")) + "\n"; out += "Velocity(orbit): " + formatDouble(telemetry.getDouble("v.orbitalVelocity")) + "\n"; out += "Speed(vert): " + formatDouble(telemetry.getDouble("v.verticalSpeed")) + "\n"; out += "Apoapsis: "; double apoapsis = telemetry.getDouble("o.ApA"); if (apoapsis < 0) { out += "[escaping]\n"; } else { out += formatDouble(telemetry.getDouble("o.ApA")) + "\n"; } double periapsis = telemetry.getDouble("o.PeA"); out += "Periapsis: " + formatDouble(periapsis) + "\n"; double electricCharge = telemetry.getDouble("r.resource[ElectricCharge]"); double electricChargeMax = telemetry.getDouble("r.resourceMax[ElectricCharge]"); double electricChargePercent = electricCharge / electricChargeMax; out += "Electric %: " + formatDouble(electricChargePercent * 100) + "\n"; double fuel = telemetry.getDouble("r.resource[LiquidFuel]"); double fuelMax = telemetry.getDouble("r.resourceMax[LiquidFuel]"); out += "Fuel %: " + formatDouble(fuel / fuelMax * 100); setText(out); } catch (JSONException e) { Log.e("Nausicaa", e.toString()); String trace = ""; for (StackTraceElement el : e.getStackTrace()) { trace += el.toString(); } Log.e("Nausicaa", trace); if (alertOutput != null) { alertOutput.alert("<<PARSE ERROR>>"); } } }
From source file:org.apache.stratos.common.concurrent.locks.ReadWriteLockMonitor.java
private String stackTraceToString(StackTraceElement[] stackTraceElements) { StringBuffer sb = new StringBuffer(); if (stackTraceElements != null) { for (StackTraceElement element : stackTraceElements) { if (element != null) { sb.append(element.toString()).append("\n"); }/* w w w . ja va2 s .c o m*/ } } return sb.toString(); }
From source file:DeadlockDetector.java
private void printThreadInfo(ThreadInfo threadInfo) { printThread(threadInfo);//from ww w.j a va2s .com sb.append(INDENT + threadInfo.toString() + "\n"); StackTraceElement[] stacktrace = threadInfo.getStackTrace(); MonitorInfo[] monitors = threadInfo.getLockedMonitors(); for (int i = 0; i < stacktrace.length; i++) { StackTraceElement ste = stacktrace[i]; sb.append(INDENT + "at " + ste.toString() + "\n"); for (MonitorInfo mi : monitors) { if (mi.getLockedStackDepth() == i) { sb.append(INDENT + " - locked " + mi + "\n"); } } } }
From source file:org.mifos.platform.validations.ValidationException.java
private void makeStackTrace(StringBuilder buffer, StackTraceElement[] stackTraceElements, String key) { buffer.append(key);/*from w w w.j av a 2 s . c om*/ if (stackTraceElements != null) { for (StackTraceElement stackTraceElement : stackTraceElements) { String stackFrameStr = stackTraceElement.toString(); if (startsWithIgnoreCase(stackFrameStr, MIFOS_PACKAGE_PREFIX)) { buffer.append("\n at ").append(stackFrameStr); } } } else { buffer.append("\n <no stack trace available>"); } buffer.append("\n"); }
From source file:org.apache.ambari.servicemonitor.reporting.restapi.RestStatusServlet.java
private void doGetProbeStatus(HttpServletRequest req, HttpServletResponse resp, ProbeStatus status) throws ServletException, IOException { boolean live = status.isSuccess(); HashMap<String, Object> map = new HashMap<String, Object>(); map.put(LIVE, live);/*from w ww.ja v a 2 s .c o m*/ map.put("timestamp", status.getTimestamp()); map.put("phase", status.getProbePhase()); map.put("message", status.getMessage()); Throwable thrown = status.getThrown(); if (thrown != null) { HashMap<String, Object> tmap = new HashMap<String, Object>(); tmap.put("message", thrown.toString()); StackTraceElement[] stackTrace = thrown.getStackTrace(); int index = 0; for (StackTraceElement elt : stackTrace) { tmap.put(Integer.toString(index++), elt.toString()); } map.put("exception", tmap); } writeJSON(resp, map, HttpServletResponse.SC_OK); }
From source file:org.apache.openejb.server.cli.StreamManager.java
public void writeErr(final Exception e) { if (e.getStackTrace() == null) { write(serr, e.getMessage());/*from w w w . j a v a 2 s .c o m*/ } else { final StringBuilder error = new StringBuilder(); error.append(e.getMessage()).append(lineSep); for (final StackTraceElement elt : e.getStackTrace()) { error.append(" ").append(elt.toString()).append(lineSep); } write(serr, error.toString()); } }
From source file:com.kotcrab.vis.editor.util.vis.CrashReporter.java
private void printThreadInfo() { println("--- Threads ---"); Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); for (Thread t : threadSet) { println("Thread: " + t.getName() + ", daemon: " + t.isDaemon() + ", state: " + t.getState()); for (StackTraceElement e : t.getStackTrace()) { crashReport.append("\t"); println(e.toString()); }/*from ww w . java2s. com*/ println(); } println("---------------"); println(); }
From source file:org.apache.hadoop.mapred.ShuffleExceptionTracker.java
private boolean checkStackException(IOException ie) { StackTraceElement[] stack = ie.getStackTrace(); for (StackTraceElement elem : stack) { String stacktrace = elem.toString(); if (stacktrace.matches(exceptionStackRegex)) { return true; }//from w w w . jav a2 s. c o m } return false; }
From source file:com.clinic.controller.BaseController.java
public void exceptionHander(HttpServletRequest request, Exception exception, HttpServletResponse response) { // //from www . ja va2s . c o m StringBuffer sb = new StringBuffer(); StackTraceElement[] stackArray = exception.getStackTrace(); for (int i = 0; i < stackArray.length; i++) { StackTraceElement element = stackArray[i]; sb.append(element.toString() + "\n"); } log.error("" + sb.toString() + "" + exception.getMessage(), exception); // ??????? if (exception instanceof ServiceException) { ServiceException e = (ServiceException) exception; switch (e.getErrorType()) { case ExceptionCode.GOODSCATEGORY_NULL_EXCEPTION: ResponseHandler.responseError(ResponseMessage.goodsCategory_dont_exist, response); break; case ExceptionCode.PRICE_ERROR: ResponseHandler.responseError(ResponseMessage.price_error, response); break; case ExceptionCode.USER_NO_LOGIN: ResponseHandler.responseApiLoginError(response); break; case ExceptionCode.DEL_GOODSCATEGORY_EXIST_PRODUCT: ResponseHandler.responseError(ResponseMessage.goodsCategory_product_error, response); break; case ExceptionCode.USER_NO_AUTHEN: ResponseHandler.responseError(ResponseMessage.account_no_auth, response); break; case ExceptionCode.SELLER_NO_OPEN_STORE: ResponseHandler.responseError(ResponseMessage.seller_no_store, response); break; case ExceptionCode.EXIST_BUSINESSLICENSENAME: ResponseHandler.responseError(ResponseMessage.exist_businesslicensename, response); break; case ExceptionCode.BUSINESSLICENSENAME_LENGTH_GT_30: ResponseHandler.responseError(ResponseMessage.businessLicenseName_length_gt_30, response); break; case ExceptionCode.BUSINESSLICENSENAME_LENGTH_LT_5: ResponseHandler.responseError(ResponseMessage.businessLicenseName_length_lt_5, response); break; default: ResponseHandler.responseServerError(response); break; } return; } if (exception instanceof com.alibaba.dubbo.rpc.RpcException) { ResponseHandler.responseServerTimeout(response); } else { ResponseHandler.responseServerError(response); } }