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

How to use
Exception
in
java.lang

Best Java code snippets using java.lang.Exception (Showing top 20 results out of 297,711)

origin: apache/incubator-dubbo

@Override
public List<String> getChildren(String path) {
  try {
    return client.getChildren().forPath(path);
  } catch (NoNodeException e) {
    return null;
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}
origin: square/okhttp

 @Override protected void execute() {
  try {
   drainQueue();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
});
origin: ReactiveX/RxJava

  @Override
  public Object apply(Long aLong) throws Exception {
    throw new Exception();
  }
});
origin: skylot/jadx

  private Exception test() {
    Exception e = new Exception();
    try {
      Thread.sleep(50);
    } catch (Exception ex) {
      e = ex;
    }
    e.printStackTrace();
    return e;
  }
}
origin: spring-projects/spring-framework

public void testCheckedThrowableSync(CacheableService<?> service) throws Exception {
  String arg = UUID.randomUUID().toString();
  try {
    service.throwCheckedSync(arg);
    fail("Excepted exception");
  }
  catch (Exception ex) {
    ex.printStackTrace();
    assertEquals("Wrong exception type", IOException.class, ex.getClass());
    assertEquals(arg, ex.getMessage());
  }
}
origin: ReactiveX/RxJava

  @Test
  @Ignore("Observers can't throw")
  public void onCompleteSuccessWithUnsubscribeFailure() {
    Subscriber<String> subscriber = subscriberSuccess();
    try {
      subscriber.onSubscribe(THROWING_DISPOSABLE);
      new SafeSubscriber<String>(subscriber).onComplete();
      fail("expects exception to be thrown");
    } catch (Exception e) {
      e.printStackTrace();

      // FIXME no longer assertable
//            assertTrue(o.isUnsubscribed());
//            assertTrue(e instanceof UnsubscribeFailedException);
      assertTrue(e.getCause() instanceof SafeSubscriberTestException);
      assertEquals("failure from unsubscribe", e.getMessage());
      // expected since onError fails so SafeSubscriber can't help
    }
  }

origin: spring-projects/spring-framework

@Test
public void handleClientMessageProcessingError() throws Exception {
  Exception ex = new Exception("fake exception");
  Message<byte[]> actual = this.handler.handleClientMessageProcessingError(null, ex);
  StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(actual, StompHeaderAccessor.class);
  assertNotNull(accessor);
  assertEquals(StompCommand.ERROR, accessor.getCommand());
  assertEquals(ex.getMessage(), accessor.getMessage());
  assertArrayEquals(new byte[0], actual.getPayload());
}
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: spring-projects/spring-framework

private void assertIsCompiled(Expression expression) {
  try {
    Field field = SpelExpression.class.getDeclaredField("compiledAst");
    field.setAccessible(true);
    Object object = field.get(expression);
    assertNotNull(object);
  }
  catch (Exception ex) {
    fail(ex.toString());
  }
}
origin: google/guava

 @Override
 public TestException apply(Exception from) {
  if (from instanceof ExecutionException) {
   return new TestException(from.getCause());
  } else {
   assertTrue(
     "got " + from.getClass(),
     from instanceof InterruptedException || from instanceof CancellationException);
   return new TestException(from);
  }
 }
};
origin: skylot/jadx

public ClassNode getClassNode(Class<?> clazz) {
  try {
    File jar = getJarForClass(clazz);
    return getClassNodeFromFile(jar, clazz.getName());
  } catch (Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  return null;
}
origin: ReactiveX/RxJava

  @Test
  @Ignore("Observers can't throw")
  public void onCompleteSuccessWithUnsubscribeFailure() {
    Observer<String> o = OBSERVER_SUCCESS();
    try {
      o.onSubscribe(THROWING_DISPOSABLE);
      new SafeObserver<String>(o).onComplete();
      fail("expects exception to be thrown");
    } catch (Exception e) {
      e.printStackTrace();

      // FIXME no longer assertable
//            assertTrue(o.isUnsubscribed());
//            assertTrue(e instanceof UnsubscribeFailedException);
      assertTrue(e.getCause() instanceof SafeObserverTestException);
      assertEquals("failure from unsubscribe", e.getMessage());
      // expected since onError fails so SafeObserver can't help
    }
  }

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: ReactiveX/RxJava

  @Test
  @Ignore("Observers can't throw")
  public void onErrorNotImplementedFailureSafe() {
    try {
      new SafeObserver<String>(OBSERVER_ONERROR_NOTIMPLEMENTED()).onError(new SafeObserverTestException("error!"));
      fail("expects exception to be thrown");
    } catch (Exception e) {
//            assertTrue(e instanceof OnErrorNotImplementedException);
      assertTrue(e.getCause() instanceof SafeObserverTestException);
      assertEquals("error!", e.getCause().getMessage());
    }
  }

origin: apache/incubator-dubbo

@Override
public String doGetContent(String path) {
  try {
    byte[] dataBytes = client.getData().forPath(path);
    return (dataBytes == null || dataBytes.length == 0) ? null : new String(dataBytes, charset);
  } catch (NoNodeException e) {
    // ignore NoNode Exception.
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
  return null;
}
origin: skylot/jadx

protected void generateClsCode(ClassNode cls) {
  try {
    new CodeGen().visit(cls);
  } catch (Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}
origin: JakeWharton/butterknife

private void logParsingError(Element element, Class<? extends Annotation> annotation,
  Exception e) {
 StringWriter stackTrace = new StringWriter();
 e.printStackTrace(new PrintWriter(stackTrace));
 error(element, "Unable to parse @%s binding.\n\n%s", annotation.getSimpleName(), stackTrace);
}
origin: ReactiveX/RxJava

  @Override
  public Object apply(Long aLong) throws Exception {
    throw new Exception();
  }
});
origin: ReactiveX/RxJava

  @Test
  @Ignore("Observers can't throw")
  public void onErrorNotImplementedFailureSafe() {
    try {
      new SafeSubscriber<String>(subscriberOnErrorNotImplemented()).onError(new SafeSubscriberTestException("error!"));
      fail("expects exception to be thrown");
    } catch (Exception e) {
//            assertTrue(e instanceof OnErrorNotImplementedException);
      assertTrue(e.getCause() instanceof SafeSubscriberTestException);
      assertEquals("error!", e.getCause().getMessage());
    }
  }

origin: spring-projects/spring-framework

  @Override
  public String handleException(Exception exception) {
    return exception.getMessage();
  }
}
java.langException

Javadoc

The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch.

The class Exception and any subclasses that are not also subclasses of RuntimeException are checked exceptions. Checked exceptions need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.

Most used methods

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

Popular in Java

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • From CI to AI: The AI layer in your organization
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