
if(typeof _ptools == 'undefined') {
	var _ptools = {};
};

/**
 * Exception Manager Klasse
 * Sammelt _ptools.Exception
 *
 * @author PCSG - Henning
 * @package _ptools
 */
_ptools.ExceptionManager = {
	
	onexception : null,
	
	active : true,
	
	history : new Array(),
	
	add : function( exep )
	{
		if(exep.type == '_ptools::Exception') {
			this.history.push( exep );
		};
		
		return true;
	}
};

/**
 * Exception Klasse
 * @author PCSG - Henning
 * @package _ptools
 */
_ptools.Exception = function( msg, c ) 
{
	var t = this; 
	t.message = '';
	t.code = parseInt(c);
	
	t.type = '_ptools::Exception';
	t.message = 'Division durch Null!'
	
	if( typeof msg == 'string' && msg.length != 0 ) {
		t.message = msg;
	};
	
	// [begin] methods
	t.toString = function() 
	{
		return t.type+ ' ' + t.getCode() +' : '+ t.getMessage();
	};
	
	t.getMessage = function()
	{
		return t.message;
	};
	
	t.getCode = function()
	{
		return t.code;
	};
};

_ptools.Exception.setError = function(msg, code)
{
	if(_ptools.ExceptionManager.active) {
		_ptools.ExceptionManager.add( new _ptools.Exception(msg, code) );
	};
};

