java.lang.IllegalStateException.printStackTrace()方法的使用及代码示例

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

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

IllegalStateException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. @Override public void onComplete() {
  2. if (subscription == null) { // Technically this check is not needed, since we are expecting Publishers to conform to the spec
  3. (new IllegalStateException("Publisher violated the Reactive Streams rule 1.09 signalling onComplete prior to onSubscribe.")).printStackTrace(System.err);
  4. } else {
  5. // Here we are not allowed to call any methods on the `Subscription` or the `Publisher`, as per rule 2.3
  6. // And anyway, the `Subscription` is considered to be cancelled if this method gets called, as per rule 2.4
  7. }
  8. }
  9. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. @Override public void onError(final Throwable t) {
  2. if (subscription == null) { // Technically this check is not needed, since we are expecting Publishers to conform to the spec
  3. (new IllegalStateException("Publisher violated the Reactive Streams rule 1.09 signalling onError prior to onSubscribe.")).printStackTrace(System.err);
  4. } else {
  5. // As per rule 2.13, we need to throw a `java.lang.NullPointerException` if the `Throwable` is `null`
  6. if (t == null) throw null;
  7. // Here we are not allowed to call any methods on the `Subscription` or the `Publisher`, as per rule 2.3
  8. // And anyway, the `Subscription` is considered to be cancelled if this method gets called, as per rule 2.4
  9. }
  10. }

代码示例来源:origin: libgdx/libgdx

  1. public void setPosition (float position) {
  2. if (player == null) return;
  3. try {
  4. if (!isPrepared) {
  5. player.prepare();
  6. isPrepared = true;
  7. }
  8. player.seekTo((int)(position * 1000));
  9. } catch (IllegalStateException e) {
  10. e.printStackTrace();
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

代码示例来源:origin: libgdx/libgdx

  1. public void setPosition (float position) {
  2. if (player == null) return;
  3. try {
  4. if (!isPrepared) {
  5. player.prepare();
  6. isPrepared = true;
  7. }
  8. player.seekTo((int)(position * 1000));
  9. } catch (IllegalStateException e) {
  10. e.printStackTrace();
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

代码示例来源:origin: libgdx/libgdx

  1. @Override
  2. public void play () {
  3. if (player == null) return;
  4. try {
  5. if (player.isPlaying()) return;
  6. } catch (Exception e) {
  7. // NOTE: isPlaying() can potentially throw an exception and crash the application
  8. e.printStackTrace();
  9. return;
  10. }
  11. try {
  12. if (!isPrepared) {
  13. player.prepare();
  14. isPrepared = true;
  15. }
  16. player.start();
  17. } catch (IllegalStateException e) {
  18. e.printStackTrace();
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. }
  22. }

代码示例来源:origin: libgdx/libgdx

  1. @Override
  2. public void play () {
  3. if (player == null) return;
  4. try {
  5. if (player.isPlaying()) return;
  6. } catch (Exception e) {
  7. // NOTE: isPlaying() can potentially throw an exception and crash the application
  8. e.printStackTrace();
  9. return;
  10. }
  11. try {
  12. if (!isPrepared) {
  13. player.prepare();
  14. isPrepared = true;
  15. }
  16. player.start();
  17. } catch (IllegalStateException e) {
  18. e.printStackTrace();
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. }
  22. }

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

  1. public long getDuration() {
  2. long duration = 0;
  3. //TODO MediaPlayer 判空的问题
  4. // if (JZMediaManager.instance().mediaPlayer == null) return duration;
  5. try {
  6. duration = JZMediaManager.getDuration();
  7. } catch (IllegalStateException e) {
  8. e.printStackTrace();
  9. return duration;
  10. }
  11. return duration;
  12. }

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

  1. @Override
  2. public void seekTo(long time) {
  3. try {
  4. mediaPlayer.seekTo((int) time);
  5. } catch (IllegalStateException e) {
  6. e.printStackTrace();
  7. }
  8. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. private void done() {
  2. //On this line we could add a guard against `!done`, but since rule 3.7 says that `Subscription.cancel()` is idempotent, we don't need to.
  3. done = true; // If we `whenNext` throws an exception, let's consider ourselves done (not accepting more elements)
  4. try {
  5. subscription.cancel(); // Cancel the subscription
  6. } catch(final Throwable t) {
  7. //Subscription.cancel is not allowed to throw an exception, according to rule 3.15
  8. (new IllegalStateException(subscription + " violated the Reactive Streams rule 3.15 by throwing an exception from cancel.", t)).printStackTrace(System.err);
  9. }
  10. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. private final void done() {
  2. //On this line we could add a guard against `!done`, but since rule 3.7 says that `Subscription.cancel()` is idempotent, we don't need to.
  3. done = true; // If `whenNext` throws an exception, let's consider ourselves done (not accepting more elements)
  4. if (subscription != null) { // If we are bailing out before we got a `Subscription` there's little need for cancelling it.
  5. try {
  6. subscription.cancel(); // Cancel the subscription
  7. } catch(final Throwable t) {
  8. //Subscription.cancel is not allowed to throw an exception, according to rule 3.15
  9. (new IllegalStateException(subscription + " violated the Reactive Streams rule 3.15 by throwing an exception from cancel.", t)).printStackTrace(System.err);
  10. }
  11. }
  12. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. private void handleOnError(final Throwable error) {
  2. if (subscription == null) { // Technically this check is not needed, since we are expecting Publishers to conform to the spec
  3. // Publisher is not allowed to signal onError before onSubscribe according to rule 1.09
  4. (new IllegalStateException("Publisher violated the Reactive Streams rule 1.09 signalling onError prior to onSubscribe.")).printStackTrace(System.err);
  5. } else {
  6. done = true; // Obey rule 2.4
  7. whenError(error);
  8. }
  9. }

代码示例来源:origin: naman14/Timber

  1. public void setVolume(final float vol) {
  2. try {
  3. mCurrentMediaPlayer.setVolume(vol, vol);
  4. } catch (IllegalStateException e) {
  5. e.printStackTrace();
  6. }
  7. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. private void handleOnComplete() {
  2. if (subscription == null) { // Technically this check is not needed, since we are expecting Publishers to conform to the spec
  3. // Publisher is not allowed to signal onComplete before onSubscribe according to rule 1.09
  4. (new IllegalStateException("Publisher violated the Reactive Streams rule 1.09 signalling onComplete prior to onSubscribe.")).printStackTrace(System.err);
  5. } else {
  6. done = true; // Obey rule 2.4
  7. whenComplete();
  8. }
  9. }

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

  1. public long getCurrentPositionWhenPlaying() {
  2. long position = 0;
  3. //TODO 这块的判断应该根据MediaPlayer来
  4. if (currentState == CURRENT_STATE_PLAYING ||
  5. currentState == CURRENT_STATE_PAUSE) {
  6. try {
  7. position = JZMediaManager.getCurrentPosition();
  8. } catch (IllegalStateException e) {
  9. e.printStackTrace();
  10. return position;
  11. }
  12. }
  13. return position;
  14. }

代码示例来源:origin: JessYanCoding/MVPArms

  1. @Override
  2. public void onDestroyView() {
  3. if (mUnbinder != null && mUnbinder != Unbinder.EMPTY) {
  4. try {
  5. mUnbinder.unbind();
  6. } catch (IllegalStateException e) {
  7. e.printStackTrace();
  8. //fix Bindings already cleared
  9. Timber.w("onDestroyView: " + e.getMessage());
  10. }
  11. }
  12. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. @Override public void onComplete() {
  2. if (subscription == null) { // Technically this check is not needed, since we are expecting Publishers to conform to the spec
  3. (new IllegalStateException("Publisher violated the Reactive Streams rule 1.09 signalling onComplete prior to onSubscribe.")).printStackTrace(System.err);
  4. } else {
  5. // Here we are not allowed to call any methods on the `Subscription` or the `Publisher`, as per rule 2.3
  6. // And anyway, the `Subscription` is considered to be cancelled if this method gets called, as per rule 2.4
  7. }
  8. }
  9. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. @Override public void onError(final Throwable t) {
  2. if (subscription == null) { // Technically this check is not needed, since we are expecting Publishers to conform to the spec
  3. (new IllegalStateException("Publisher violated the Reactive Streams rule 1.09 signalling onError prior to onSubscribe.")).printStackTrace(System.err);
  4. } else {
  5. // As per rule 2.13, we need to throw a `java.lang.NullPointerException` if the `Throwable` is `null`
  6. if (t == null) throw null;
  7. // Here we are not allowed to call any methods on the `Subscription` or the `Publisher`, as per rule 2.3
  8. // And anyway, the `Subscription` is considered to be cancelled if this method gets called, as per rule 2.4
  9. }
  10. }

代码示例来源:origin: naman14/Timber

  1. public void setDataSource(final String path) {
  2. try {
  3. mIsInitialized = setDataSourceImpl(mCurrentMediaPlayer, path);
  4. if (mIsInitialized) {
  5. setNextDataSource(null);
  6. }
  7. } catch (IllegalStateException e) {
  8. e.printStackTrace();
  9. }
  10. }

代码示例来源:origin: reactive-streams/reactive-streams-jvm

  1. private void done() {
  2. //On this line we could add a guard against `!done`, but since rule 3.7 says that `Subscription.cancel()` is idempotent, we don't need to.
  3. done = true; // If we `whenNext` throws an exception, let's consider ourselves done (not accepting more elements)
  4. try {
  5. subscription.cancel(); // Cancel the subscription
  6. } catch(final Throwable t) {
  7. //Subscription.cancel is not allowed to throw an exception, according to rule 3.15
  8. (new IllegalStateException(subscription + " violated the Reactive Streams rule 3.15 by throwing an exception from cancel.", t)).printStackTrace(System.err);
  9. }
  10. }

代码示例来源:origin: spring-projects/spring-framework

  1. @Override
  2. public Object invoke(MethodInvocation mi) throws Throwable {
  3. String task = "get invocation on way IN";
  4. try {
  5. MethodInvocation current = ExposeInvocationInterceptor.currentInvocation();
  6. assertEquals(mi.getMethod(), current.getMethod());
  7. Object retval = mi.proceed();
  8. task = "get invocation on way OUT";
  9. assertEquals(current, ExposeInvocationInterceptor.currentInvocation());
  10. return retval;
  11. }
  12. catch (IllegalStateException ex) {
  13. System.err.println(task + " for " + mi.getMethod());
  14. ex.printStackTrace();
  15. throw ex;
  16. }
  17. }
  18. }

相关文章