Codota Logo
Throwable.getStackTrace
Code IndexAdd Codota to your IDE (free)

How to use
getStackTrace
method
in
java.lang.Throwable

Best Java code snippets using java.lang.Throwable.getStackTrace (Showing top 20 results out of 15,669)

  • Common ways to obtain Throwable
private void myMethod () {
Throwable t =
  • Codota IconInvocationTargetException e;e.getTargetException()
  • Codota IconInvocationTargetException e;e.getCause()
  • Codota IconException e;e.getCause()
  • Smart code suggestions by Codota
}
origin: org.mockito/mockito-core

private LocationImpl(StackTraceFilter stackTraceFilter, Throwable stackTraceHolder) {
  this.stackTraceFilter = stackTraceFilter;
  this.stackTraceHolder = stackTraceHolder;
  if (stackTraceHolder.getStackTrace() == null || stackTraceHolder.getStackTrace().length == 0) {
    //there are corner cases where exception can have a null or empty stack trace
    //for example, a custom exception can override getStackTrace() method
    this.sourceFile = "<unknown source file>";
  } else {
    this.sourceFile = stackTraceFilter.findSourceFile(stackTraceHolder.getStackTrace(), "<unknown source file>");
  }
}
origin: spring-projects/spring-framework

@Override
public boolean matches(Method method, Class<?> targetClass, Object... args) {
  this.evaluations++;
  for (StackTraceElement element : new Throwable().getStackTrace()) {
    if (element.getClassName().equals(this.clazz.getName()) &&
        (this.methodName == null || element.getMethodName().equals(this.methodName))) {
      return true;
    }
  }
  return false;
}
origin: ReactiveX/RxJava

private void appendStackTrace(StringBuilder b, Throwable ex, String prefix) {
  b.append(prefix).append(ex).append('\n');
  for (StackTraceElement stackElement : ex.getStackTrace()) {
    b.append("\t\tat ").append(stackElement).append('\n');
  }
  if (ex.getCause() != null) {
    b.append("\tCaused by: ");
    appendStackTrace(b, ex.getCause(), "");
  }
}
origin: libgdx/libgdx

private String getStackTrace (Throwable e) {
  StringBuilder sb = new StringBuilder();
  for (StackTraceElement trace : e.getStackTrace()) {
    sb.append(trace.toString() + "\n");
  }
  return sb.toString();
}
origin: libgdx/libgdx

private String getStackTrace (Throwable e) {
  StringBuilder sb = new StringBuilder();
  for (StackTraceElement trace : e.getStackTrace()) {
    sb.append(trace.toString() + "\n");
  }
  return sb.toString();
}
origin: apache/incubator-dubbo

  @Override
  public void writeObject(Object obj, AbstractHessianOutput out)
      throws IOException {
    Throwable e = (Throwable) obj;

    e.getStackTrace();

    super.writeObject(obj, out);
  }
}
origin: skylot/jadx

private static void filter(Throwable th) {
  StackTraceElement[] stackTrace = th.getStackTrace();
  int cutIndex = -1;
  int length = stackTrace.length;
  for (int i = 0; i < length; i++) {
    StackTraceElement stackTraceElement = stackTrace[i];
    if (stackTraceElement.getClassName().startsWith(JADX_API_PACKAGE)) {
      cutIndex = i;
    } else if (cutIndex > 0) {
      cutIndex = i;
      break;
    }
  }
  if (cutIndex > 0 && cutIndex < length) {
    th.setStackTrace(Arrays.copyOfRange(stackTrace, 0, cutIndex));
  }
}
origin: alibaba/druid

public void setExecuteErrorLast(Throwable executeErrorLast) {
  this.executeErrorLast = executeErrorLast;
  if (executeErrorLast != null) {
    this.executeErrorLastMessage = executeErrorLast.getMessage();
    this.executeErrorLastClass = executeErrorLast.getClass().getName();
    this.executeErrorLastStackTrace = Utils.toString(executeErrorLast.getStackTrace());
  }
}
origin: alibaba/druid

public void setLastError(Throwable lastError) {
  if (lastError != null) {
    lastErrorClass = lastError.getClass().getName();
    lastErrorMessage = lastError.getMessage();
    lastErrorStackTrace = Utils.toString(lastError.getStackTrace());
  }
}
origin: org.mockito/mockito-core

@Override
public String toString() {
  //TODO SF perhaps store the results after invocation?
  StackTraceElement[] filtered = stackTraceFilter.filter(stackTraceHolder.getStackTrace(), false);
  if (filtered.length == 0) {
    return "-> at <<unknown line>>";
  }
  return "-> at " + filtered[0].toString();
}
origin: google/guava

private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
 Throwable cause = e.getCause();
 if (cause == null) {
  throw e;
 }
 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;
}
origin: redisson/redisson

  public RedissonKryoCodecException(Throwable cause) {
    super(cause.getMessage(), cause);
    setStackTrace(cause.getStackTrace());
  }
}
origin: redisson/redisson

private void appendStackTrace(StringBuilder b, Throwable ex, String prefix) {
  b.append(prefix).append(ex).append('\n');
  for (StackTraceElement stackElement : ex.getStackTrace()) {
    b.append("\t\tat ").append(stackElement).append('\n');
  }
  if (ex.getCause() != null) {
    b.append("\tCaused by: ");
    appendStackTrace(b, ex.getCause(), "");
  }
}
origin: jenkinsci/jenkins

/**
 * @deprecated as of 1.305 use {@link #getEnvironment(TaskListener)}
 */
@Deprecated
public EnvVars getEnvironment() throws IOException, InterruptedException {
  LOGGER.log(WARNING, "deprecated call to Run.getEnvironment\n\tat {0}", new Throwable().getStackTrace()[1]);
  return getEnvironment(new LogTaskListener(LOGGER, Level.INFO));
}
origin: spring-projects/spring-framework

private void resolve() {
  StackTraceElement[] stack = new Throwable().getStackTrace();
  String sourceClassName = null;
  String sourceMethodName = null;
  boolean found = false;
  for (StackTraceElement element : stack) {
    String className = element.getClassName();
    if (FQCN.equals(className)) {
      found = true;
    }
    else if (found) {
      sourceClassName = className;
      sourceMethodName = element.getMethodName();
      break;
    }
  }
  setSourceClassName(sourceClassName);
  setSourceMethodName(sourceMethodName);
}
origin: org.mockito/mockito-core

  public void filter(Throwable throwable) {
    if (!config.cleansStackTrace()) {
      return;
    }
    StackTraceElement[] filtered = filter.filter(throwable.getStackTrace(), true);
    throwable.setStackTrace(filtered);
  }
}
origin: org.mockito/mockito-core

private static Object tryInvoke(Method origin, Object instance, Object[] arguments) throws Throwable {
  try {
    return origin.invoke(instance, arguments);
  } catch (InvocationTargetException exception) {
    Throwable cause = exception.getCause();
    new ConditionalStackTraceFilter().filter(hideRecursiveCall(cause, new Throwable().getStackTrace().length, origin.getDeclaringClass()));
    throw cause;
  }
}
origin: spring-projects/spring-framework

private boolean contain(Throwable t, String className, String methodName) {
  for (StackTraceElement element : t.getStackTrace()) {
    if (className.equals(element.getClassName()) && methodName.equals(element.getMethodName())) {
      return true;
    }
  }
  return false;
}
origin: ch.qos.logback/logback-classic

public static void build(ThrowableProxy nestedTP, Throwable nestedThrowable, ThrowableProxy parentTP) {
  StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace();
  int commonFramesCount = -1;
  if (parentTP != null) {
    commonFramesCount = findNumberOfCommonFrames(nestedSTE, parentTP.getStackTraceElementProxyArray());
  }
  nestedTP.commonFrames = commonFramesCount;
  nestedTP.stackTraceElementProxyArray = steArrayToStepArray(nestedSTE);
}
origin: org.mockito/mockito-core

public void appendWarnings(Failure failure, String warnings) {
  if (isEmpty(warnings)) {
    return;
  }
  //TODO: this has to protect the use in case jUnit changes and this internal state logic fails
  Throwable throwable = (Throwable) getInternalState(failure, "fThrownException");
  String newMessage = "contains both: actual test failure *and* Mockito warnings.\n" +
      warnings + "\n *** The actual failure is because of: ***\n";
  ExceptionIncludingMockitoWarnings e = new ExceptionIncludingMockitoWarnings(newMessage, throwable);
  e.setStackTrace(throwable.getStackTrace());
  setInternalState(failure, "fThrownException", e);
}
java.langThrowablegetStackTrace

Javadoc

Returns a clone of the array of stack trace elements of this Throwable. Each StackTraceElement represents an entry in the call stack. The element at position 0 is the top of the stack, that is, the stack frame where this Throwable is thrown.

Popular methods of Throwable

  • getMessage
    Returns the detail message string of this throwable.
  • printStackTrace
  • getCause
    Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is th
  • toString
    Returns a short description of this throwable. The result is the concatenation of: * the Class#getN
  • <init>
    Constructs a new throwable with the specified cause and a detail message of (cause==null ? null : ca
  • getLocalizedMessage
    Creates a localized description of this throwable. Subclasses may override this method in order to p
  • setStackTrace
    Sets the stack trace elements that will be returned by #getStackTrace() and printed by #printStackTr
  • addSuppressed
    Appends the specified exception to the exceptions that were suppressed in order to deliver this exce
  • initCause
    Initializes the cause of this throwable to the specified value. (The cause is the throwable that cau
  • fillInStackTrace
  • getSuppressed
    Returns the throwables suppressed by this.
  • countDuplicates
    Counts the number of duplicate stack frames, starting from the end of the stack.
  • getSuppressed,
  • countDuplicates,
  • getInternalStackTrace,
  • nativeFillInStackTrace,
  • nativeGetStackTrace,
  • fillInStackTrace0,
  • genStackTrace,
  • genStackTraceFromError,
  • getOurStackTrace

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Menu (java.awt)
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now