var Cathmhaol = window.Cathmhaol || {};

/**
* Creates an error object.
*
* @author	Robert King (hrobertking@cathmhaol.com)
*
* @example	try { //code } catch(err) { var oError = new Cathmhaol.Error(); oError.raise(err, "my code", 1000); }
*/
Cathmhaol.Error = function() {
	/**
	* @property	The description of the error.
	* @type	{string}
	*/
	this.description = null;

	/**
	* @property	The number of the error
	* @type	{integer}
	*/
	this.errNumber = null;

	/**
	* @method	Clears the error detail
	* @returns	{void}
	*/
	clear: function() {
		me.source = "";
		me.description = "Unspecified Error";
		me.errNumber = 0;
	};

	/**
	* @method	Raises and error and shows it
	* @returns	{void}
	* @argument	{object} objError
	* @argument	{string} source
	* @argument	{integer} errNumber
	*/
	this.raise = function(objError, source, errNumber) {
		window.status = "";
		if (source) { me.source = source; }
		if (objError) { me.description = (objError.description ? objError.description : objError); }
		if (errNumber) { me.errNumber = errNumber; }
		me.show();
	};

	/**
	* @method	Displays the error
	* @returns	{void}
	*/
	this.show = function() {
		window.status = "";
		alert("ERROR"+(me.errNumber !=0 ? " #" + me.errNumber : "") + "\n\n" + (me.source != "" ? "SOURCE: " + me.source + "\n\n" : "") + me.description);
	};

	/**
	* @property    source
	* @description The source of the error
	* @type {string}
	*/
	this.source = null;

	var me = this;
	me.source = "";
	me.description = "Unspecified Error";
	me.errNumber = 0;
};

