/**
 * Part of JMF Library core
 * This file contains exception class definitions for JMF library
 * SVN: $Id: exception.js 6163 2008-08-14 14:36:31Z mjezierski $
 */

JMF.registerLib('JMF.Exception','$Id: exception.js 6163 2008-08-14 14:36:31Z mjezierski $');

/**
 * Exception class
 * @constructor
 * @member JMF.Exception
 * @param {Object} exceptionData Exception data object. Null or JMF.Exception.EX_nnnn constant can be used
 * @param {String} text Alternate exception text
 */
JMF.Exception = function(exceptionData,text) {
   if(typeof exceptionData !== 'object') {
   	this.code = JMF.Exception.EX_UNKNOWN.code;
   	this.text = exceptionData; 
   }
   this.code = exceptionData.code;
   this.text = text || exceptionData.text;  
};

/**
 * Overriden toString method for Exception class
 * @return {String} Exception string 
 */
JMF.Exception.prototype.toString = function() {
	return 'JMF Exception: code: ' + this.code + '. message: '+ this.text;
};

//Constant for unknown error
JMF.Exception.EX_UNKNOWN      = {code:-1,text:'Unknown error'};
//Constant for object not found error
JMF.Exception.EX_OBJNOTFOUND  = {code:-2,text:'Object not found'};
//Constant for no id error
JMF.Exception.EX_NOID         = {code:-3,text:'ID is required'};
//Constant for invalid parameters error
JMF.Exception.EX_INVPARAMS    = {code:-4,text:'Invalid parameters'};
//Constatnt for not supported feature error
JMF.Exception.EX_NOTSUPPORTED    = {code:-5,text:'Feature is not supported'};