Tabnine Logo
Throwable.getCause
Code IndexAdd Tabnine to your IDE (free)

How to use
getCause
method
in
java.lang.Throwable

Best Java code snippets using java.lang.Throwable.getCause (Showing top 20 results out of 31,743)

origin: spring-projects/spring-framework

/**
 * Check "javax.servlet.error.exception" attribute for a multipart exception.
 */
private boolean hasMultipartException(HttpServletRequest request) {
  Throwable error = (Throwable) request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE);
  while (error != null) {
    if (error instanceof MultipartException) {
      return true;
    }
    error = error.getCause();
  }
  return false;
}
origin: ReactiveX/RxJava

private List<Throwable> getListOfCauses(Throwable ex) {
  List<Throwable> list = new ArrayList<Throwable>();
  Throwable root = ex.getCause();
  if (root == null || root == ex) {
    return list;
  } else {
    while (true) {
      list.add(root);
      Throwable cause = root.getCause();
      if (cause == null || cause == root) {
        return list;
      } else {
        root = cause;
      }
    }
  }
}
origin: spring-projects/spring-framework

/**
 * Check the source behind this error: possibly an {@link Exception}
 * (typically {@link org.springframework.beans.PropertyAccessException})
 * or a Bean Validation {@link javax.validation.ConstraintViolation}.
 * <p>The cause of the outermost exception will be introspected as well,
 * e.g. the underlying conversion exception or exception thrown from a setter
 * (instead of having to unwrap the {@code PropertyAccessException} in turn).
 * @return whether this error has been caused by a source object of the given type
 * @since 5.0.4
 */
public boolean contains(Class<?> sourceType) {
  return (sourceType.isInstance(this.source) ||
      (this.source instanceof Throwable && sourceType.isInstance(((Throwable) this.source).getCause())));
}
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: apache/incubator-dubbo

@Override
protected int getErrorCode(Throwable e) {
  if (e instanceof Fault) {
    e = e.getCause();
  }
  if (e instanceof SocketTimeoutException) {
    return RpcException.TIMEOUT_EXCEPTION;
  } else if (e instanceof IOException) {
    return RpcException.NETWORK_EXCEPTION;
  }
  return super.getErrorCode(e);
}
origin: ReactiveX/RxJava

private static Throwable getRootCause(Throwable ex) {
  Throwable root = ex.getCause();
  if (root == null) {
    return null;
  } else {
    while (true) {
      if (root.getCause() == null) {
        return root;
      } else {
        root = root.getCause();
      }
    }
  }
}
origin: apache/incubator-dubbo

@Override
protected int getErrorCode(Throwable e) {
  if (e instanceof Fault) {
    e = e.getCause();
  }
  if (e instanceof SocketTimeoutException) {
    return RpcException.TIMEOUT_EXCEPTION;
  } else if (e instanceof IOException) {
    return RpcException.NETWORK_EXCEPTION;
  }
  return super.getErrorCode(e);
}
origin: google/guava

 /**
  * Appends the chain of messages from the {@code conflictingStackTrace} to the original {@code
  * message}.
  */
 @Override
 public String getMessage() {
  StringBuilder message = new StringBuilder(super.getMessage());
  for (Throwable t = conflictingStackTrace; t != null; t = t.getCause()) {
   message.append(", ").append(t.getMessage());
  }
  return message.toString();
 }
}
origin: google/guava

private static void rethrow(ExecutionException e) throws ExecutionException {
 Throwable wrapper = e.getCause();
 if (wrapper instanceof WrapperException) {
  Throwable cause = wrapper.getCause();
  if (cause instanceof RuntimeException) {
   throw (RuntimeException) cause;
  } else if (cause instanceof Error) {
   throw (Error) cause;
  }
 }
 throw e;
}
origin: spring-projects/spring-framework

@Nullable
private HttpStatus resolveStatus(Throwable ex) {
  HttpStatus status = determineStatus(ex);
  if (status == null) {
    Throwable cause = ex.getCause();
    if (cause != null) {
      status = resolveStatus(cause);
    }
  }
  return status;
}
origin: spring-projects/spring-framework

@Override
public boolean matches(Object item) {
  Throwable cause = null;
  if (item != null && item instanceof Throwable) {
    cause = ((Throwable)item).getCause();
  }
  return matcher.matches(cause);
}
origin: skylot/jadx

private static void filterRecursive(Throwable th) {
  try {
    filter(th);
  } catch (Exception e) {
    // ignore filter exceptions
  }
  Throwable cause = th.getCause();
  if (cause != null) {
    filterRecursive(cause);
  }
}
origin: ReactiveX/RxJava

public static void assertUndeliverable(List<Throwable> list, int index, Class<? extends Throwable> clazz) {
  Throwable ex = list.get(index);
  if (!(ex instanceof UndeliverableException)) {
    AssertionError err = new AssertionError("Outer exception UndeliverableException expected but got " + list.get(index));
    err.initCause(list.get(index));
    throw err;
  }
  ex = ex.getCause();
  if (!clazz.isInstance(ex)) {
    AssertionError err = new AssertionError("Inner exception " + clazz + " expected but got " + list.get(index));
    err.initCause(list.get(index));
    throw err;
  }
}
origin: ReactiveX/RxJava

/**
 * Cast the given Throwable to CompositeException and returns its inner
 * Throwable list.
 * @param ex the target Throwable
 * @return the list of Throwables
 */
public static List<Throwable> compositeList(Throwable ex) {
  if (ex instanceof UndeliverableException) {
    ex = ex.getCause();
  }
  return ((CompositeException)ex).getExceptions();
}
origin: ReactiveX/RxJava

static void assertUndeliverableTestException(List<Throwable> list, int index, String message) {
  assertTrue(list.get(index).toString(), list.get(index).getCause() instanceof TestException);
  assertEquals(message, list.get(index).getCause().getMessage());
}
origin: ReactiveX/RxJava

@Test
public void nullRootCause() {
  RuntimeException te = new RuntimeException() {
    private static final long serialVersionUID = -8492568224555229753L;
    @Override
    public Throwable getCause() {
      return null;
    }
  };
  assertSame(te, new CompositeException(te).getCause().getCause());
  assertSame(te, new CompositeException(new RuntimeException(te)).getCause().getCause().getCause());
}
origin: ReactiveX/RxJava

    @Override
    public void onError(Throwable e) {
      String trace = stackTraceAsString(e);
      System.out.println("On Error: " + trace);

      assertTrue(trace, trace.contains("OnNextValue"));

      assertTrue("No Cause on throwable" + e, e.getCause() != null);
//            assertTrue(e.getCause().getClass().getSimpleName() + " no OnNextValue",
//                    e.getCause() instanceof OnErrorThrowable.OnNextValue);
    }

origin: ReactiveX/RxJava

@Test
public void badException() {
  Throwable e = new BadException();
  assertSame(e, new CompositeException(e).getCause().getCause());
  assertSame(e, new CompositeException(new RuntimeException(e)).getCause().getCause().getCause());
}
origin: ReactiveX/RxJava

@After
public void after() {
  RxJavaPlugins.reset();
  assertFalse("" + errors, errors.isEmpty());
  TestHelper.assertError(errors, 0, OnErrorNotImplementedException.class);
  Throwable c = errors.get(0).getCause();
  assertTrue("" + c, c instanceof TestException);
}
origin: ReactiveX/RxJava

@Test
public void subscribeZeroError() {
  List<Throwable> errors = TestHelper.trackPluginErrors();
  try {
    assertTrue(Maybe.error(new TestException())
    .subscribe().isDisposed());
    TestHelper.assertError(errors, 0, OnErrorNotImplementedException.class);
    Throwable c = errors.get(0).getCause();
    assertTrue("" + c, c instanceof TestException);
  } finally {
    RxJavaPlugins.reset();
  }
}
java.langThrowablegetCause

Javadoc

Returns the cause of this Throwable, or null if there is no cause.

Popular methods of Throwable

  • getMessage
    Returns the detail message string of this throwable.
  • printStackTrace
  • toString
    Returns a short description of this throwable. The result is the concatenation of: * the Class#getN
  • getStackTrace
    Provides programmatic access to the stack trace information printed by #printStackTrace(). Returns a
  • <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

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JOptionPane (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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