congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Exception.getStackTrace
Code IndexAdd Tabnine to your IDE (free)

How to use
getStackTrace
method
in
java.lang.Exception

Best Java code snippets using java.lang.Exception.getStackTrace (Showing top 20 results out of 7,002)

origin: jenkinsci/jenkins

public LegacyCodeCause() {
  stackTrace = new Exception().getStackTrace();
}
origin: redisson/redisson

/**
 * Returns current stack trace in form of array of stack trace elements.
 * First stack trace element is removed.
 * Since an exception is thrown internally, this method is slow.
 */
@SuppressWarnings({"ThrowCaughtLocally"})
public static StackTraceElement[] getCurrentStackTrace() {
  StackTraceElement[] ste = new Exception().getStackTrace();
  if (ste.length > 1) {
    StackTraceElement[] result = new StackTraceElement[ste.length - 1];
    System.arraycopy(ste, 1, result, 0, ste.length - 1);
    return result;
  } else {
    return ste;
  }
}
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: aa112901/remusic

public static String getExceptionMessage(Exception ex) {
  String result = "";
  StackTraceElement[] stes = ex.getStackTrace();
  for (int i = 0; i < stes.length; i++) {
    result = result + stes[i].getClassName() + "." + stes[i].getMethodName() + "  " + stes[i].getLineNumber()
        + "line" + "\r\n";
  }
  return result;
}
origin: h2oai/h2o-2

public HTTP500V1( Exception e ) { 
 error = e.getClass().getSimpleName()+": "+e.getMessage();
 stackTrace = Arrays.toString(e.getStackTrace());
}
@Override public HTTP500V1 fillInto( Handler h ) { throw H2O.fail(); }
origin: airbnb/epoxy

EpoxyProcessorException(Exception e, String message) {
 super(message, e);
 setStackTrace(e.getStackTrace());
}
origin: gocd/gocd

public static void addDeveloperErrorMessage(Map jsonMap, Exception e) {
  addFriendlyErrorMessage(jsonMap, e.getMessage() + ": " + e.getCause() + " at " + e.getStackTrace()[0]);
}
origin: prestodb/presto

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: quartz-scheduler/quartz

private Exception newPlainException(Exception e) {
  String type = e.getClass().getName();
  if(type.startsWith("java.") || type.startsWith("javax.")) {
    return e;
  } else {
    Exception result = new Exception(e.getMessage());
    result.setStackTrace(e.getStackTrace());
    return result;
  }
}

origin: wildfly/wildfly

  private static <T extends Throwable> T copyContents(final Exception source, final T throwable) {
    throwable.setStackTrace(source.getStackTrace());
    final Throwable[] suppressed = source.getSuppressed();
    if (suppressed != null) for (final Throwable t : suppressed) {
      throwable.addSuppressed(t);
    }
    return throwable;
  }
}
origin: h2oai/h2o-2

public static void POST(int n, Exception e) {
  if (e.getMessage() != null) {
    POST(n, e.getMessage());
  }
  POST(n, e.toString());
  StackTraceElement[] els = e.getStackTrace();
  for (int i = 0; i < els.length; i++) {
    POST(n, els[i].toString());
  }
}
public static void POST(int n) {
origin: spring-projects/spring-framework

@Test
public void fillInClientStackTraceIfPossibleSunnyDay() throws Exception {
  try {
    throw new IllegalStateException("Mmm");
  }
  catch (Exception ex) {
    int originalStackTraceLngth = ex.getStackTrace().length;
    RemoteInvocationUtils.fillInClientStackTraceIfPossible(ex);
    assertTrue("Stack trace not being filled in",
        ex.getStackTrace().length > originalStackTraceLngth);
  }
}
origin: spring-projects/spring-framework

StackTraceElement[] callStack = new Exception().getStackTrace();
StackTraceElement[] cachedCallStack = exception.getStackTrace();
origin: eclipse-vertx/vert.x

protected void afterAsyncTestBase() {
 if (throwable != null && thrownThread != Thread.currentThread() && !awaitCalled) {
  // Throwable caught from non main thread
  throw new IllegalStateException("Assert or failure from non main thread but no await() on main thread", throwable);
 }
 if (lateFailure) {
  throw new IllegalStateException("Test reported a failure after completion");
 }
 for (Map.Entry<String, Exception> entry: threadNames.entrySet()) {
  if (!entry.getKey().equals(mainThreadName)) {
   if (threadChecksEnabled && !entry.getKey().startsWith("vert.x-")) {
    IllegalStateException is = new IllegalStateException("Non Vert.x thread! :" + entry.getKey());
    is.setStackTrace(entry.getValue().getStackTrace());
    throw is;
   }
  }
 }
}
origin: SonarSource/sonarqube

public static RuntimeException translateException(String msg, Exception cause) {
 RuntimeException runtimeException = new RuntimeException(String.format("%s: [%s] %s", msg, cause.getClass().getName(), cause.getMessage()));
 runtimeException.setStackTrace(cause.getStackTrace());
 return runtimeException;
}
origin: apache/hive

static void debugTrace() {
 if (LOG.isDebugEnabled()){
  Exception e = new Exception();
  LOG.debug("." + e.getStackTrace()[1].getLineNumber() + ":" + TestObjectStoreInitRetry.getInjectConnectFailure());
 }
}
origin: gocd/gocd

void cleanAndResetToMaster() throws IOException {
  try {
    git.reset().setMode(ResetCommand.ResetType.HARD).call();
    checkout("master");
    deleteBranch(BRANCH_AT_REVISION);
    deleteBranch(BRANCH_AT_HEAD);
  } catch (Exception e) {
    String currentBranch = git.getRepository().getBranch();
    LOGGER.error("Error while trying to clean up config repository, CurrentBranch: {} \n : \n Message: {} \n StackTrace: {}", currentBranch, e.getMessage(), e.getStackTrace(), e);
    throw new RuntimeException(e);
  }
}
origin: spring-projects/spring-framework

@Test
public void findMethodAnnotationOnBridgeMethod() throws Exception {
  Method bridgeMethod = SimpleFoo.class.getMethod("something", Object.class);
  assertTrue(bridgeMethod.isBridge());
  assertNull(bridgeMethod.getAnnotation(Order.class));
  assertNull(getAnnotation(bridgeMethod, Order.class));
  assertNotNull(findAnnotation(bridgeMethod, Order.class));
  boolean runningInEclipse = Arrays.stream(new Exception().getStackTrace())
      .anyMatch(element -> element.getClassName().startsWith("org.eclipse.jdt"));
  // As of JDK 8, invoking getAnnotation() on a bridge method actually finds an
  // annotation on its 'bridged' method [1]; however, the Eclipse compiler will not
  // support this until Eclipse 4.9 [2]. Thus, we effectively ignore the following
  // assertion if the test is currently executing within the Eclipse IDE.
  //
  // [1] https://bugs.openjdk.java.net/browse/JDK-6695379
  // [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=495396
  //
  if (!runningInEclipse) {
    assertNotNull(bridgeMethod.getAnnotation(Transactional.class));
  }
  assertNotNull(getAnnotation(bridgeMethod, Transactional.class));
  assertNotNull(findAnnotation(bridgeMethod, Transactional.class));
}
origin: google/guava

@GwtIncompatible // lazyStackTrace
private void doTestLazyStackTraceFallback() {
 assertFalse(lazyStackTraceIsLazy());
 Exception e = new Exception();
 assertThat(lazyStackTrace(e)).containsExactly((Object[]) e.getStackTrace()).inOrder();
 try {
  lazyStackTrace(e).set(0, null);
  fail();
 } catch (UnsupportedOperationException expected) {
 }
 e.setStackTrace(new StackTraceElement[0]);
 assertThat(lazyStackTrace(e)).isEmpty();
}
origin: google/guava

@GwtIncompatible // lazyStackTrace(Throwable)
public void testLazyStackTrace() {
 Exception e = new Exception();
 StackTraceElement[] originalStackTrace = e.getStackTrace();
 assertThat(lazyStackTrace(e)).containsExactly((Object[]) originalStackTrace).inOrder();
 try {
  lazyStackTrace(e).set(0, null);
  fail();
 } catch (UnsupportedOperationException expected) {
 }
 // Now we test a property that holds only for the lazy implementation.
 if (!lazyStackTraceIsLazy()) {
  return;
 }
 e.setStackTrace(new StackTraceElement[0]);
 assertThat(lazyStackTrace(e)).containsExactly((Object[]) originalStackTrace).inOrder();
}
java.langExceptiongetStackTrace

Popular methods of Exception

  • getMessage
  • printStackTrace
  • <init>
    Constructs a new exception with the specified cause and a detail message of (cause==null ? null : c
  • toString
  • getCause
  • getLocalizedMessage
  • addSuppressed
  • initCause
  • fillInStackTrace
  • setStackTrace
  • getSuppressed
  • logWithStack
  • getSuppressed,
  • logWithStack

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now