List of usage examples for java.lang Throwable getStackTrace
public StackTraceElement[] getStackTrace()
From source file:com.elusive_code.newsboy.EventNotifierTask.java
private void updateStackTrace(Throwable ex) { if (eventStackTrace == null) return;/*from w w w.j a v a 2 s . c o m*/ try { StackTraceElement[] stack1 = ex.getStackTrace(); StackTraceElement[] stack2 = eventStackTrace.getStackTrace(); StackTraceElement[] result = ArrayUtils.addAll(stack1, stack2); ex.setStackTrace(result); } catch (Throwable t) { LOG.log(Level.FINE, "Failed to update stack trace for " + ex, t); } }
From source file:org.broadleafcommerce.openadmin.web.handler.AdminMappingExceptionResolver.java
/** * By default, appends the exception and its message followed by the file location that triggered this exception. * Recursively builds this out for each cause of the given exception. * // w w w . j a v a2 s . co m * @param throwable * @param sb */ protected void appendStackTrace(Throwable throwable, StringBuilder sb) { if (throwable == null) { return; } StackTraceElement[] st = throwable.getStackTrace(); if (st != null && st.length > 0) { sb.append("\r\n\r\n"); sb.append(throwable.toString()); sb.append("\r\n"); sb.append(st[0].toString()); } appendStackTrace(throwable.getCause(), sb); }
From source file:org.objectweb.proactive.core.body.future.ContextAwareMethodCallResult.java
/** * @param result the method call's result * @param exception the exception thrown during the method call execution */// www .java 2 s . co m public ContextAwareMethodCallResult(Object result, Throwable exception, StackTraceElement[] context) { super(result, exception); if (exception != null && context != null) { StackTraceElement[] stack = ArrayUtils.addAll(exception.getStackTrace(), context); exception.setStackTrace(stack); } }
From source file:com.github.lynxdb.server.api.http.ErrorResponse.java
private void parseException(Throwable _thrw, StringBuilder _builder) { _builder.append(_thrw.getClass().getName()).append(": ").append(_thrw.getMessage()); for (StackTraceElement ste : _thrw.getStackTrace()) { _builder.append("\t").append(ste.toString()).append("\n"); }/*from w ww . j a v a 2 s. co m*/ if (_thrw.getCause() != null) { _builder.append("Caused by :"); parseException(_thrw.getCause(), _builder); } }
From source file:fi.jumi.core.api.StackTraceTest.java
@Test public void has_same_stack_trace_as_original_exception() { Throwable original = new Throwable("original message"); StackTrace copy = StackTrace.from(original); assertThat(copy.getStackTrace(), is(arrayContaining(original.getStackTrace()))); assertThat(Throwables.getStackTraceAsString(copy), is(Throwables.getStackTraceAsString(original))); }
From source file:fr.putnami.pwt.core.service.server.service.AbstractCommandExecutor.java
protected Throwable toThrown(String message, Throwable source) { CommandException thrown = new CommandException(message, source); if (source != null) { StringBuilder buf = new StringBuilder(); for (StackTraceElement element : source.getStackTrace()) { buf.append(element.toString()).append("\n"); }//from w w w .ja v a2s . com thrown.setCauseStackTrace(buf.toString()); } return thrown; }
From source file:com.opengamma.engine.depgraph.ExceptionWrapper.java
private ExceptionWrapper(final Throwable exception, final ExceptionWrapper cause) { _exception = exception;//w w w .j a v a 2 s .c om _message = exception.getMessage(); final StackTraceElement[] trace = exception.getStackTrace(); if (trace.length > 0) { _topStackFrame = trace[0]; } else { _topStackFrame = null; } _cause = cause; _count = 1; }
From source file:com.nts.alphamale.handler.FollowerHandler.java
/*** * ??? record ?? /*from w ww .jav a 2 s .co m*/ * @param job */ @Subscribe @AllowConcurrentEvents public void task(Job job) { Job rjob = null; try { rjob = (Job) job.clone(); if (isLeader == false) { if (rjob.getJobType() == JobType.POSITION_BASE) { rjob.convertPoint(deviceInfo); } } else { return; } Object rsltObj = client.invoke(rjob); if (rsltObj instanceof Boolean) { boolean isSuccess = (Boolean) rsltObj; ExecutionLogManager.add(rjob.getSeq(), rjob.getTitle(), serial, deviceInfo.getModel(), isSuccess, "unknown"); } } catch (Throwable e) { log.info("Exception Follower(" + deviceInfo.getModel() + ") - " + e.getStackTrace()); ExecutionLogManager.add(rjob.getSeq(), rjob.getTitle(), serial, deviceInfo.getModel(), false, e.getLocalizedMessage()); } finally { ExecutionLogManager.send(rjob.getSeq(), false); } }
From source file:org.tap4j.ext.testng.TestNGYAMLishUtils.java
/** * @param testNgTestResult/*from w w w. j av a2 s. co m*/ * @return Line value */ public static String getLine(ITestResult testNgTestResult) { String line = "~"; Throwable testNGException = testNgTestResult.getThrowable(); if (testNGException != null) { StringBuilder lookFor = new StringBuilder(); lookFor.append(testNgTestResult.getTestClass().getName()); lookFor.append('.'); lookFor.append(testNgTestResult.getMethod().getMethodName()); lookFor.append('('); lookFor.append(testNgTestResult.getTestClass().getClass().getSimpleName()); lookFor.append(".java:"); StackTraceElement[] els = testNGException.getStackTrace(); for (int i = 0; i < els.length; i++) { StackTraceElement el = els[i]; line = getLineNumberFromExceptionTraceLine(el.toString(), lookFor.toString()); if (line != "") { break; } } } return line; }
From source file:net.sourceforge.atunes.ErrorReport.java
/** * Returns string information about throwable * /*from w ww . j a va2 s. co m*/ * @return */ private String getThrowableString() { List<String> values = new ArrayList<String>(); values.add(StringUtils.getString(this.throwable.getClass().getCanonicalName(), ": ", this.throwable.getMessage())); for (StackTraceElement ste : this.throwable.getStackTrace()) { values.add(StringUtils.getString(ste.toString())); } Throwable cause = this.throwable.getCause(); if (cause != null && cause.getStackTrace() != null) { values.add("Cause: "); for (StackTraceElement ste : cause.getStackTrace()) { values.add(StringUtils.getString(ste.toString())); } } return org.apache.commons.lang.StringUtils.join(values, "\n"); }