/************************************************
* Columbia University CS Department
* Network Security Lab
*
* Open and Survivable Embedded Systems (OASES)
*
* Structured Policy Command Language (SPCL)
*
*
* This software is provided as is without any
* warranty or guarantee of merchantibility
* or fitness for a particular purpose. This
* software is released under the terms of the
* GNU General Public License (GPL).
*
* Last updated: March 28, 2003
*
***********************************************/

package spcl.data;

/** 
 * A robust utility for the different types of
 * high-level errors that can be caused during
 * the loading, resolution, querying, and 
 * retiring of policy.
 *
 * Types need maintenance. (setType() & explain())
 *
 * @author locasto@cs.columbia.edu
 *
*/
public class PolicyException extends Exception{

    public static final int DEFAULT_ERROR = 100;
    public static final int UNABLE_TO_LOAD_POLICY = 150;
	public static final int POLICY_INCONSISTENT = 152;
	public static final int NULL_ZONE = 155;
	public static final int NULL_POLICY = 156;
	public static final int NULL_LOADER = 157;

	/** ..others as needed */

	private int type = PolicyException.DEFAULT_ERROR;

	public PolicyException( String m ){
		super( m );
	}
	
	public PolicyException( String m, int t ){
	  super( m );
	  setType( t );
	}
	
	public void setType( int t ){
	   switch( t ){
	      case PolicyException.UNABLE_TO_LOAD_POLICY : type = t; break;
	      default: type = PolicyException.DEFAULT_ERROR;
	   }
	}
	
	public String explain( int error ){
	
		switch( error ){
			case DEFAULT_ERROR: 

				break;

			case UNABLE_TO_LOAD_POLICY:

				break;

			case NULL_ZONE:

				break;
			default: return "Unrecognized error code ["+error+"]";
		}
		return "";
	}

}
