List of usage examples for java.lang StackTraceElement getMethodName
public String getMethodName()
From source file:org.kantega.notsoserial.DefaultNotSoSerial.java
private void registerDeserialization(String className) { if (!deserializingClasses.contains(className)) { deserializingClasses.add(className); String prettyName = className.replace('/', '.'); dryRunWriter.println(prettyName); dryRunWriter.flush();// w w w . j a v a 2 s . c o m if (traceWriter != null) { traceWriter .println("Deserialization of class " + prettyName + " (on " + new Date().toString() + ")"); boolean foundReadObject = false; for (StackTraceElement element : Thread.currentThread().getStackTrace()) { if (foundReadObject) { traceWriter.println("\t at " + element.getClassName() + "." + element.getMethodName()); } else if (element.getClassName().equals(ObjectInputStream.class.getName()) && element.getMethodName().equals("readObject")) { foundReadObject = true; } } } } }
From source file:org.collectionspace.chain.csp.webui.main.StreamUIRequest.java
private void exception_to_text_internal(StringBuffer buf, Throwable e) { buf.append("Exception " + e.getClass() + " thrown message=\"" + e.getMessage() + "\"\n"); for (StackTraceElement el : e.getStackTrace()) { buf.append(el.getClassName() + " " + el.getMethodName() + " (" + el.getFileName() + ":" + el.getLineNumber() + ")\n"); }/* ww w. ja va 2 s. c om*/ Throwable next = e.getCause(); if (next != null && next != e) { buf.append("Caused by:\n"); exception_to_text_internal(buf, next); } }
From source file:org.jtrfp.trcl.flow.GameShell.java
private void throwable2StringBuilder(Throwable e, StringBuilder sb) { assert e != null; assert sb != null; sb.append(e.getClass().getName() + " " + e.getLocalizedMessage() + "\n"); final StackTraceElement[] stackTraceElements = e.getStackTrace(); for (StackTraceElement ste : stackTraceElements) sb.append("\tat " + ste.getClassName() + "." + ste.getMethodName() + "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")\n"); }
From source file:com.zacwolf.commons.wbxcon.WBXCONorg.java
private final static String getMethodName(final int level) { final StackTraceElement element = Thread.currentThread().getStackTrace()[level]; return element.getClassName() + "." + element.getMethodName(); }
From source file:net.logstash.logback.LogstashFormatter.java
private void createFields(ILoggingEvent event, Context context, ObjectNode eventNode) { final Marker marker = event.getMarker(); eventNode.put("logger_name", event.getLoggerName()); eventNode.put("thread_name", event.getThreadName()); eventNode.put("level", event.getLevel().toString()); eventNode.put("level_value", event.getLevel().toInt()); if (includeCallerInfo) { StackTraceElement callerData = extractCallerData(event); eventNode.put("caller_class_name", callerData.getClassName()); eventNode.put("caller_method_name", callerData.getMethodName()); eventNode.put("caller_file_name", callerData.getFileName()); eventNode.put("caller_line_number", callerData.getLineNumber()); }/* w ww . j a v a 2 s . co m*/ IThrowableProxy throwableProxy = event.getThrowableProxy(); if (throwableProxy != null) { eventNode.put("stack_trace", ThrowableProxyUtil.asString(throwableProxy)); } if (context != null) { addPropertiesAsFields(eventNode, context.getCopyOfPropertyMap()); } if (marker != null && marker.contains("JSON")) { eventNode.put("json_message", getJsonNode(event)); } addPropertiesAsFields(eventNode, event.getMDCPropertyMap()); addCustomFields(eventNode); }
From source file:edu.wustl.lookingglass.issue.ExceptionPane.java
public String getErrorMessage() { if (this.getRootThrowable() != null) { String key = this.getRootThrowable().getClass().getSimpleName(); StackTraceElement[] trace = this.getRootThrowable().getStackTrace(); for (StackTraceElement element : trace) { String marker = element.getClassName() + "." + element.getMethodName(); if (this.getRootThrowable().getClass().equals(AssertionError.class)) { switch (marker) { case "org.alice.stageide.StageIDE.setProject": key += "." + marker; break; }//from ww w . jav a 2 s . c o m } } try { return getLocalizedString(key); } catch (MissingResourceException e) { return null; } } else { return null; } }
From source file:com.stackify.log.log4j2.LogEventAdapter.java
/** * @see com.stackify.api.common.log.EventAdapter#getLogMsg(java.lang.Object, com.google.common.base.Optional) *///from w w w. j a va2 s .c o m @Override public LogMsg getLogMsg(final LogEvent event, final StackifyError error) { LogMsg.Builder builder = LogMsg.newBuilder(); builder.msg(getMessage(event)); Map<String, String> props = getProperties(event); if (!props.isEmpty()) { try { builder.data(json.writeValueAsString(props)); } catch (Exception e) { // do nothing } } builder.ex(error); builder.th(event.getThreadName()); builder.epochMs(event.getTimeMillis()); builder.level(event.getLevel().toString().toLowerCase()); String transactionId = APMLogData.isLinked() ? APMLogData.getTransactionId() : ServletLogContext.getTransactionId(); if (transactionId != null) { builder.transId(transactionId); } StackTraceElement source = event.getSource(); if (source != null) { builder.srcMethod(source.getClassName() + "." + source.getMethodName()); try { builder.srcLine(source.getLineNumber()); } catch (Throwable e) { } } return builder.build(); }
From source file:com.bstek.dorado.idesupport.resolver.RobotResolver.java
protected void assembleError(Document document, Element responseElement, Exception error) { String message = error.getMessage(); if (message == null) { message = error.getClass().getSimpleName(); }/*from ww w . jav a 2 s .c om*/ Element messageElement = document.createElement("Message"); messageElement.appendChild(document.createTextNode(message)); responseElement.appendChild(messageElement); Element stackTraceElement = document.createElement("StackTrace"); responseElement.appendChild(stackTraceElement); StackTraceElement[] stackTrace = error.getStackTrace(); for (StackTraceElement ste : stackTrace) { Element element = document.createElement("Element"); element.setAttribute("className", ste.getClassName()); element.setAttribute("methodName", ste.getMethodName()); element.setAttribute("fileName", ste.getFileName()); element.setAttribute("lineNumber", String.valueOf(ste.getLineNumber())); stackTraceElement.appendChild(element); } }
From source file:org.eclipse.jubula.client.ui.rcp.Plugin.java
/** * checks if the exception is caused by a known Content Assist problem * @param t the Throwable which was caught in the error handler * @return true if the exception was cause by a known Content Assist bug *//*from w ww .ja v a 2 s .co m*/ public static boolean isContentAssistException(Throwable t) { Throwable work = t; do { if (work instanceof NullPointerException) { StackTraceElement[] stack = work.getStackTrace(); for (StackTraceElement el : stack) { // check for // NPE in recomputeProposals if (Messages.RecomputeProposals.equals(el.getMethodName())) { return true; } } } work = work.getCause(); } while (work != null); return false; }
From source file:com.l2jfree.mmocore.network.MMOLogger.java
private void log(Level level, String message, Throwable throwable) { if (_logger.isLoggable(level)) { final StackTraceElement caller = new Throwable().getStackTrace()[2]; final String className = caller.getClassName(); final String methodName = caller.getMethodName(); final MMOLogEntry entry = new MMOLogEntry(level, className, methodName, message, throwable); synchronized (_logEntries) { final Integer count = _logEntries.get(entry); _logEntries.put(entry, count == null ? 1 : count + 1); }//from w ww . j av a 2s. c o m } }