Tabnine Logo
Exception.initCause
Code IndexAdd Tabnine to your IDE (free)

How to use
initCause
method
in
java.lang.Exception

Best Java code snippets using java.lang.Exception.initCause (Showing top 20 results out of 2,358)

origin: com.h2database/h2

private static <T extends Exception> T initCause(T e, Object... arguments) {
  int size = arguments.length;
  if (size > 0) {
    Object o = arguments[size - 1];
    if (o instanceof Throwable) {
      e.initCause((Throwable) o);
    }
  }
  return e;
}
origin: org.osgi/org.osgi.core

/**
 * Initializes the cause of this exception to the specified value.
 * 
 * @param cause The cause of this exception.
 * @return This exception.
 * @throws IllegalArgumentException If the specified cause is this
 *         exception.
 * @throws IllegalStateException If the cause of this exception has already
 *         been set.
 * @since 1.3
 */
@Override
public Throwable initCause(Throwable cause) {
  return super.initCause(cause);
}
origin: org.osgi/org.osgi.core

  /**
   * Initializes the cause of this exception to the specified value.
   * 
   * @param cause The cause of this exception.
   * @return This exception.
   * @throws IllegalArgumentException If the specified cause is this
   *         exception.
   * @throws IllegalStateException If the cause of this exception has already
   *         been set.
   * @since 1.3
   */
  @Override
  public Throwable initCause(Throwable cause) {
    return super.initCause(cause);
  }
}
origin: org.osgi/org.osgi.compendium

/**
 * Initializes the cause of this exception to the specified value.
 * 
 * @param cause The cause of this exception.
 * @return This exception.
 * @throws IllegalArgumentException If the specified cause is this
 *         exception.
 * @throws IllegalStateException If the cause of this exception has already
 *         been set.
 * @since 1.1
 */
public Throwable initCause(Throwable cause) {
  return super.initCause(cause);
}
origin: org.osgi/org.osgi.compendium

/**
 * Initializes the cause of this exception to the specified value.
 * 
 * @param cause The cause of this exception.
 * @return This exception.
 * @throws IllegalArgumentException If the specified cause is this
 *         exception.
 * @throws IllegalStateException If the cause of this exception has already
 *         been set.
 * @since 1.0.1
 */
public Throwable initCause(Throwable cause) {
  return super.initCause(cause);
}
origin: org.osgi/org.osgi.compendium

  /**
   * Initializes the cause of this exception to the specified value.
   * 
   * @param cause The cause of this exception.
   * @return This exception.
   * @throws IllegalArgumentException If the specified cause is this
   *         exception.
   * @throws IllegalStateException If the cause of this exception has already
   *         been set.
   * @since 1.1
   */
  public Throwable initCause(Throwable cause) {
    return super.initCause(cause);
  }
}
origin: org.osgi/org.osgi.compendium

  /**
   * Initializes the cause of this exception to the specified value.
   * 
   * @param cause The cause of this exception.
   * @return This exception.
   * @throws IllegalArgumentException If the specified cause is this
   *         exception.
   * @throws IllegalStateException If the cause of this exception has already
   *         been set.
   * @since 1.2
   */
  public Throwable initCause(Throwable cause) {
    return super.initCause(cause);
  }
}
origin: org.osgi/org.osgi.compendium

  /**
   * Initializes the cause of this exception to the specified value.
   * 
   * @param cause The cause of this exception.
   * @return This exception.
   * @throws IllegalArgumentException If the specified cause is this
   *         exception.
   * @throws IllegalStateException If the cause of this exception has already
   *         been set.
   * @since 1.2
   */
  public Throwable initCause(Throwable cause) {
    return super.initCause(cause);
  }
}
origin: lealone/Lealone

private static <T extends Exception> T initCause(T e, Object... arguments) {
  int size = arguments.length;
  if (size > 0) {
    Object o = arguments[size - 1];
    if (o instanceof Exception) {
      e.initCause((Exception) o);
    }
  }
  return e;
}
origin: jenkinsci/jenkins

public synchronized void abort(Throwable cause) {
  interrupted = new AbortException();
  if (cause!=null)
    interrupted.initCause(cause);
  notifyAll();
}
origin: google/guava

private static <X extends Exception> X newWithCause(Class<X> exceptionClass, Throwable cause) {
 // getConstructors() guarantees this as long as we don't modify the array.
 @SuppressWarnings({"unchecked", "rawtypes"})
 List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
 for (Constructor<X> constructor : preferringStrings(constructors)) {
  @Nullable X instance = newFromConstructor(constructor, cause);
  if (instance != null) {
   if (instance.getCause() == null) {
    instance.initCause(cause);
   }
   return instance;
  }
 }
 throw new IllegalArgumentException(
   "No appropriate constructor for exception of type "
     + exceptionClass
     + " in response to chained exception",
   cause);
}
origin: prestodb/presto

private static <X extends Exception> X newWithCause(Class<X> exceptionClass, Throwable cause) {
 // getConstructors() guarantees this as long as we don't modify the array.
 @SuppressWarnings({"unchecked", "rawtypes"})
 List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
 for (Constructor<X> constructor : preferringStrings(constructors)) {
  @NullableDecl X instance = newFromConstructor(constructor, cause);
  if (instance != null) {
   if (instance.getCause() == null) {
    instance.initCause(cause);
   }
   return instance;
  }
 }
 throw new IllegalArgumentException(
   "No appropriate constructor for exception of type "
     + exceptionClass
     + " in response to chained exception",
   cause);
}
origin: google/j2objc

private static <X extends Exception> X newWithCause(Class<X> exceptionClass, Throwable cause) {
 // getConstructors() guarantees this as long as we don't modify the array.
 @SuppressWarnings({"unchecked", "rawtypes"})
 List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
 for (Constructor<X> constructor : preferringStrings(constructors)) {
  @NullableDecl X instance = newFromConstructor(constructor, cause);
  if (instance != null) {
   if (instance.getCause() == null) {
    instance.initCause(cause);
   }
   return instance;
  }
 }
 throw new IllegalArgumentException(
   "No appropriate constructor for exception of type "
     + exceptionClass
     + " in response to chained exception",
   cause);
}
origin: google/guava

public void testGetRootCause_Loop() {
 Exception cause = new Exception();
 Exception exception = new Exception(cause);
 cause.initCause(exception);
 try {
  Throwables.getRootCause(cause);
  fail("Should have throw IAE");
 } catch (IllegalArgumentException expected) {
  assertThat(expected).hasCauseThat().isSameAs(cause);
 }
}
origin: org.apache.logging.log4j/log4j-core

  /**
   * .
   */
  @Test
  public void testCircularCauseExceptions() {
    final Exception e1 = new Exception();
    final Exception e2 = new Exception(e1);
    e1.initCause(e2);
    LogManager.getLogger().error("Error", e1);
  }
}
origin: google/guava

public void testGetCasualChainLoop() {
 Exception cause = new Exception();
 Exception exception = new Exception(cause);
 cause.initCause(exception);
 try {
  Throwables.getCausalChain(cause);
  fail("Should have throw IAE");
 } catch (IllegalArgumentException expected) {
  assertThat(expected).hasCauseThat().isSameAs(cause);
 }
}
origin: apache/hive

 public void testExceptionConversion() {
  Exception ex1 = createException();
  ex1.initCause(createSimpleCause());
  Throwable ex = HiveSQLException.toCause(HiveSQLException.toString(ex1));
  Assert.assertSame(RuntimeException.class, ex.getClass());
  Assert.assertEquals("exception1", ex.getMessage());
  Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass());
  Assert.assertEquals("exception2", ex.getCause().getMessage());
 }
};
origin: confluentinc/ksql

@Test
public void shouldHandleRecursiveExceptionChain() {
 final Exception cause = new TestException("Something went wrong");
 final Throwable e = new TestException("Top level", cause);
 cause.initCause(e);
 assertThat(
   buildErrorMessage(e),
   is("Top level" + System.lineSeparator()
     + "Caused by: Something went wrong")
 );
}
origin: apache/hive

/**
 * Tests the conversion between the exception text with the simple cause and the
 * Throwable object
 */
@Test
public void testExceptionMarshalling() throws Exception {
 Exception ex1 = createException();
 ex1.initCause(createSimpleCause());
 Throwable ex = HiveSQLException.toCause(HiveSQLException.toString(ex1));
 Assert.assertSame(RuntimeException.class, ex.getClass());
 Assert.assertEquals("exception1", ex.getMessage());
 Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass());
 Assert.assertEquals("exception2", ex.getCause().getMessage());
}
origin: apache/hive

/**
 * Tests the conversion from a regular exception to the TStatus object
 */
@Test
public void testExceptionToTStatus() {
 Exception ex1 = createException();
 ex1.initCause(createSimpleCause());
 TStatus status = HiveSQLException.toTStatus(ex1);
 Assert.assertEquals(TStatusCode.ERROR_STATUS, status.getStatusCode());
 Assert.assertEquals(ex1.getMessage(), status.getErrorMessage());
 Assert.assertEquals(HiveSQLException.toString(ex1), status.getInfoMessages());
}
java.langExceptioninitCause

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
  • getStackTrace
  • addSuppressed
  • fillInStackTrace
  • setStackTrace
  • getSuppressed
  • logWithStack
  • getSuppressed,
  • logWithStack

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setRequestProperty (URLConnection)
  • getExternalFilesDir (Context)
  • Kernel (java.awt.image)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • CodeWhisperer alternatives
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