java.lang.RuntimeException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中java.lang.RuntimeException.<init>()方法的一些代码示例,展示了RuntimeException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RuntimeException.<init>()方法的具体详情如下:
包路径:java.lang.RuntimeException
类名称:RuntimeException
方法名:<init>

RuntimeException.<init>介绍

[英]Constructs a new RuntimeException that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新RuntimeException。

代码示例

代码示例来源:origin: ReactiveX/RxJava

static void sleep(int millis) {
    try {
      Thread.sleep(millis);
    } catch (InterruptedException ex) {
      throw new RuntimeException(ex);
    }
  }
}

代码示例来源:origin: iluwatar/java-design-patterns

@Override
public void run() {
 try (Socket socket = new Socket(InetAddress.getLocalHost(), serverPort)) {
  OutputStream outputStream = socket.getOutputStream();
  PrintWriter writer = new PrintWriter(outputStream);
  sendLogRequests(writer, socket.getInputStream());
 } catch (IOException e) {
  LOGGER.error("error sending requests", e);
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public SingleSource<Integer> apply(final Integer integer) throws Exception {
    throw new RuntimeException("something went terribly wrong!");
  }
})

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Throwable call() {
    return new RuntimeException();
  }
});

代码示例来源:origin: ReactiveX/RxJava

@Override
  public R apply(T t1) {
    throw new RuntimeException("Forced failure");
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void run() {
    throw new RuntimeException("failed on second one too");
  }
}));

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void accept(Long n) {
    throw new RuntimeException();
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void onNext(Long args) {
    throw new RuntimeException("forced failure");
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void onNext(Long args) {
    throw new RuntimeException("forced failure");
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Map<Integer, Collection<String>> call() {
    throw new RuntimeException("Forced failure");
  }
};

代码示例来源:origin: ReactiveX/RxJava

public void waitToFinish() {
  try {
    t.join();
  } catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: ReactiveX/RxJava

public void waitToFinish() {
    try {
      t.join();
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

protected void captureMaxThreads() {
  int concurrentThreads = threadsRunning.get();
  int maxThreads = maxConcurrentThreads.get();
  if (concurrentThreads > maxThreads) {
    maxConcurrentThreads.compareAndSet(maxThreads, concurrentThreads);
    if (concurrentThreads > 1) {
      new RuntimeException("should not be greater than 1").printStackTrace();
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Observable<?> apply(Observable<? extends Throwable> t1) {
    return Observable.error(new RuntimeException());
  }
}).subscribe(observer);

代码示例来源: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

@Test
public void ambIterableOrder() {
  Completable error = Completable.error(new RuntimeException());
  Completable.amb(Arrays.asList(Completable.complete(), error)).test().assertComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void assertNotSubscribed() {
  TestObserver<Integer> to = new TestObserver<Integer>();
  to.assertNotSubscribed();
  to.errors().add(new TestException());
  try {
    to.assertNotSubscribed();
    throw new RuntimeException("Should have thrown!");
  } catch (AssertionError ex) {
    // expected
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void assertValueSetOnlyThrowsWhenCompleted() {
  TestObserver<Integer> to = TestObserver.create();
  to.onSubscribe(Disposables.empty());
  to.onComplete();
  try {
    to.assertValueSetOnly(Collections.<Integer>emptySet());
    throw new RuntimeException();
  } catch (AssertionError ex) {
    // expected
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void singleOrErrorError() {
  Observable.error(new RuntimeException("error"))
    .singleOrError()
    .test()
    .assertNoValues()
    .assertErrorMessage("error")
    .assertError(RuntimeException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void ambWithOrder() {
  Flowable<Integer> error = Flowable.error(new RuntimeException());
  Flowable.just(1).ambWith(error).test().assertValue(1).assertComplete();
}

相关文章