baseexception.java

来自「JSF例子 JSF标签 用户角色控制 比较全的例子」· Java 代码 · 共 97 行

JAVA
97
字号
package org.jia.ptrack.domain;

/**
 * The base class for all exceptions. This class can wrap
 * other exceptions.
 *
 * @author Kito D. Mann
 */
public class BaseException
    extends java.lang.Exception
{
  private String message = "";
  private Exception exception = null;

  public BaseException()
  {
    super();
  }

  public BaseException(String message)
  {
    super();
    this.message = message;
    this.exception = null;
  }

  public BaseException(Exception e)
  {
    super();
    this.message = this.getClass().getName();
    this.exception = e;
  }

  public BaseException(String message, Exception e)
  {
    super();
    this.message = message;
    this.exception = e;
  }

  public String getMessage()
  {
    if ( ( (message == null) || (message.length() == 0)) && exception != null)
    {
      return exception.getMessage();
    }
    else
    {
      return this.message;
    }
  }

  public Exception getException()
  {
    return exception;
  }

  public String toString()
  {
    return getMessage();
  }

  public void printStackTrace()
  {
    super.printStackTrace();
    if (exception != null)
    {
      System.err.println();
      System.err.println("Embedded exception:");
      exception.printStackTrace();
    }
  }

  public void printStackTrace(java.io.PrintStream s)
  {
    super.printStackTrace(s);
    if (exception != null)
    {
      s.println();
      s.println("Embedded exception:");
      exception.printStackTrace(s);
    }
  }

  public void printStackTrace(java.io.PrintWriter s)
  {
    super.printStackTrace(s);
    if (exception != null)
    {
      s.println();
      s.println("Embedded exception:");
      exception.printStackTrace(s);
    }
  }

}

⌨️ 快捷键说明

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