*
int_error - Se trata de un flag de error.
*
* - 0. No hay errores.
* - 1. Hay un error.
*
*
* str_descError - Contiene la descripción del error a mostrar
*
*
* @version $Id: IgepError.php,v 1.19 2011-03-14 11:34:26 afelixf Exp $
* @author David:
* @author Keka:
* @author Vero:
* @author Raquel:
* @author Toni:
* @package gvHIDRA
*/
class IgepError{
/**
* flag de error
*
* @var integer int_flag
*/
var $int_flag;
/**
* código de error
*
* @var string str_codigoError
*/
var $str_codigoError;
/**
* Descripción del error
*
* @var string str_fichero
*/
var $str_fichero;
/**
* Descripción del error
*
* @var string str_funcion
*/
var $str_funcion;
/**
* DB error
*
* @var objeto obj_dbError
*/
var $obj_dbError;
/**
* Constructor
*
* @access public
*/
function IgepError(){
$this->limpiarError();
}
/**
* Para indicar la existencia de un error. Activa el flag y
* almacena el valor del texto del error. En
*
* @access public
* @param string $descError
*/
function setError($codigoError,$fichero,$funcion,$dbError="",$codigoSQL="") {
$this->int_flag = 1;
$this->str_codigoError = $codigoError;
$this->str_fichero = $fichero;
$this->str_funcion = $funcion;
$this->obj_dbError=$dbError;
//Marcamos el error en el debug
$descripcion = $this->getDescErrorDB();
if($codigoSQL!='')
IgepDebug::setDebug(ERROR,'ERROR al ejecutar : '.$codigoSQL);
if(isset($descripcion[0]))
IgepDebug::setDebug(ERROR,$descripcion[0]);
}
/**
* Desactiva el flag de error.
*
* @access public
*/
function limpiarError() {
$this->int_flag = 0;
$this->str_codigoError = "";
unset($this->str_funcion);
unset($this->str_fichero);
unset($this->obj_dbError);
}
/**
* Devuelve el codigo de error del error almacenado.
*
* @access public
* @return integer
*/
function getError() {
return $this->str_codigoError;
}
/**
* Devuelve el string de descripción del error de la base de datos.
*
* @access public
* @return array
*/
public function getDescErrorDB() {
$descripcion = array();
if(isset($this->obj_dbError->userinfo)){
//Mensaje al usuario
$descripcion[0]=$this->obj_dbError->message;
//Mensaje al debugger
$posInicial = strpos($this->obj_dbError->userinfo,"[");
$mensaje = substr($this->obj_dbError->userinfo,$posInicial +12);
if($mensaje!="")
$debug = $mensaje;
else
$debug = $this->obj_dbError->message;
//Quitamos las comillas, los corchetes y los \n.
$debug = str_replace("'","",$debug);
$debug = str_replace("\n","",$debug);
$debug = str_replace("]","",$debug);
$debug = trim($debug);
IgepDebug::setDebug(ERROR,$debug);
}
return $descripcion;
}
/**
* Devuelve el flag de error.
*
* @access public
* @return integer
*/
function hayError() {
return $this->int_flag;
}
function setMsjError(& $mensaje) {
$mensaje->setMensaje($this->getError(),$this->getDescErrorDB());
$this->limpiarError();
}
}//Fin de IgepError
?>