*
  • int_error - Se trata de un flag de error. * *
  • *
  • str_descError - Contiene la descripción del error a mostrar
  • * * * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License v.2 * @version $Id: IgepError.php,v 1.19 2018-08-11 11:34:26 belenguer_jor Exp $ * @author David Pascual * @author Keka Bermejo * @author Vero Navarro * @author Raquel Borjabad * @author Toni Felix * @author Jorge Belenguer * * @package gvHidra */ class IgepError { /** * Flag de error. * @var integer */ public $int_flag; /** * Código de error. * @var string */ public $str_codigoError; /** * Descripción del error. * * @var string */ public $str_fichero; /** * Función * * @var string */ public $str_funcion; /** * DB error * @var PEAR_Error */ public $obj_dbError; /** * Constructor */ public function __construct() { $this->limpiarError(); } //Fin del constructor /** * Para indicar la existencia de un error. Activa el flag y almacena el valor del texto del error. * * @param string $codigoError * @param string $fichero * @param string $funcion * @param PEAR_Error $dbError (Opcional) * @param string $codigoSQL (Opcional) */ public function setError( $codigoError, $fichero, $funcion, $dbError=null, $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]}" ); } } //Fin de setError /** * Desactiva el flag de error. */ public function limpiarError() { $this->int_flag = 0; $this->str_codigoError = ''; unset( $this->str_fichero ); unset( $this->str_funcion ); unset( $this->obj_dbError ); } //Fin de limpiarError /** * Devuelve el codigo de error del error almacenado. * * @return integer */ function getError() { return $this->str_codigoError; } //Fin de getError /** * Devuelve un array con la descripción del error de la base de datos. * * @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 ); $debug = (!empty($mensaje) ? $mensaje : $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; } //Fin de getDescErrorDB /** * Devuelve el flag de error. * * @return integer */ public function hayError() { return $this->int_flag; } //Fin de hayError /** * Establece el mensaje de error. * * @param IgepMensaje $mensaje */ public function setMsjError( & $mensaje) { $mensaje->setMensaje( $this->getError(), $this->getDescErrorDB() ); $this->limpiarError(); } //Fin de setMsjError } //End IgepError