TKException.java :  » Content-Management-System » webman » com » teamkonzept » lib » Java Open Source

Java Open Source » Content Management System » webman 
webman » com » teamkonzept » lib » TKException.java
package com.teamkonzept.lib;

import java.io.*;

/**
    this is the wrapper class for all Exceptions
 * @author  $Author: alexandergrosse $
 * @version $Revision: 1.7.6.1 $
*/
public class TKException
    extends Exception
    implements ErrorCodes
{
    private int errorCode;
    private Throwable originalException;

    /** exception public to the user ? */
    private boolean isPublic;

    private int severity;

    /** Values for the error templates */
    private TKHashtable params = null;

    // Optional arguments for message formatting.
    private Object[] arguments = null;

    /**
      constructor, if the error was detected without a thrown exception,
      e.g. by testing some values
    */
    public TKException (String description,
                        int _errorCode,
                        int _severity,
                        boolean _ispublic,
                        Throwable t)
    {
      this(description, _errorCode, _severity, _ispublic, null, t);
    }

    public TKException (String description,
                        int _errorCode,
                        int _severity,
                        boolean _ispublic,
                        Object[] arguments,
                        Throwable t)
    {
      super(description);
      errorCode = _errorCode;
      originalException = t;
      severity = _severity;
      isPublic = _ispublic;
        this.arguments = arguments;
    }

    public void setParams(TKHashtable _hash)
    {
      params = _hash;
    }

    public Throwable getOriginalException()
    {
      return originalException;
    }

    public int getErrorCode()
    {
      return errorCode;
    }

    public boolean isPublic()
    {
      return isPublic;
    }

    public int getSeverity()
    {
      return severity;
    }

    public Object[] getArguments ()
    {
        return arguments;
    }

    /**
      Convenience
    */
    public String getFullStackTrace()
    {
      if (originalException == null)
        return "";
      StringWriter strWriter = new StringWriter();
      PrintWriter pw = new PrintWriter(strWriter);
      originalException.printStackTrace(pw);
      pw.close();
      return strWriter.getBuffer().toString();
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.