⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nestedruntimeexception.java

📁 数据库连接池源码
💻 JAVA
字号:
package llm.pool.relation.mydatasource;

public class NestedRuntimeException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4287089057406736915L;

	private static final String CAUSED_BY = "\nCaused by: ";

	  private Throwable cause = null;

	  /**
	   * Constructor
	   */
	  public NestedRuntimeException() {
	  }

	  /**
	   * Constructor
	   *
	   * @param msg error message
	   */
	  public NestedRuntimeException(String msg) {
	    super(msg);
	  }

	  /**
	   * Constructor
	   *
	   * @param cause the nested exception (caused by)
	   */
	  public NestedRuntimeException(Throwable cause) {
	    super();
	    this.cause = cause;
	  }

	  /**
	   * Constructor
	   *
	   * @param msg   error message
	   * @param cause the nested exception (caused by)
	   */
	  public NestedRuntimeException(String msg, Throwable cause) {
	    super(msg);
	    this.cause = cause;
	  }

	  /**
	   * Gets the causing exception, if any.
	   *
	   * @return The cause of the exception
	   */
	  public Throwable getCause() {
	    return cause;
	  }

	  /**
	   * Converts the exception to a string representation
	   *
	   * @return The string representation of the exception
	   */
	  public String toString() {
	    if (cause == null) {
	      return super.toString();
	    } else {
	      return super.toString() + CAUSED_BY + cause.toString();
	    }
	  }

	  /**
	   * Sends a stack trace to System.err (including the root cause, if any)
	   */
	  public void printStackTrace() {
	    super.printStackTrace();
	    if (cause != null) {
	      System.err.println(CAUSED_BY);
	      cause.printStackTrace();
	    }
	  }

	  /**
	   * Sends a stack trace to the PrintStream passed in (including the root cause, if any)
	   *
	   * @param ps - the PrintStream to send the output to
	   */
	  public void printStackTrace(java.io.PrintStream ps) {
	    super.printStackTrace(ps);
	    if (cause != null) {
	      ps.println(CAUSED_BY);
	      cause.printStackTrace(ps);
	    }
	  }

	  /**
	   * Sends a stack trace to the PrintWriter passed in (including the root cause, if any)
	   *
	   * @param pw - the PrintWriter to send the output to
	   */
	  public void printStackTrace(java.io.PrintWriter pw) {
	    super.printStackTrace(pw);
	    if (cause != null) {
	      pw.println(CAUSED_BY);
	      cause.printStackTrace(pw);
	    }
	  }

	}

⌨️ 快捷键说明

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