exceptioncontainer.java

来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 42 行

JAVA
42
字号
package org.uispec4j.utils;

public class ExceptionContainer {
  private RuntimeException exception;
  private Error error;

  public void set(Throwable e) {
    if (e instanceof RuntimeException) {
      exception = (RuntimeException)e;
    }
    else if (e instanceof Error) {
      error = (Error)e;
    }
    else {
      exception = new RuntimeException(e);
    }
  }

  public boolean isSet() {
    return (exception != null) || (error != null);
  }

  public void rethrowIfNeeded() {
    try {
      if (error != null) {
        throw error;
      }
      if (exception != null) {
        throw exception;
      }
    }
    finally {
      reset();
    }
  }

  public void reset() {
    exception = null;
    error = null;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?