Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/07/2013, 19:58
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Problema raro: Excepcion no-capturada

Colegas:

Me esta pasando algo "raro" porque tengo dentro una clase algo no mucho mas complicado que esto... y la excepcion jamas es capturada, termina arrojando "Fatal error" ... por que puede pasar ?

Código PHP:
   <?php
    
try 
        {
            throw new 
Exception ("Algo anda mal"); 
            
        }catch (
Exception $e){
            echo 
'Error capturado: '$e->getMessage(), "\n"
        }

    echo 
"// La vida sigue..";

Gracias desde ya

Código PHP:
Ver original
  1. public function consistencyCheck($strict_error=false){
  2.  
  3.         $intersec = array_intersect($this->_must_contain,$this->_must_not_contain);          
  4.  
  5.         try
  6.         {
  7.  
  8.         if (!empty($intersec))
  9.             throw new \Exception ("Los tags que no deben estar, no pueden ser los mismos que deben estar (contradiccion)");
  10.             ///return false;
  11.  
  12.        
  13.         if (!empty($this->_can_contain))
  14.         {
  15.             // el universo de lo posible de ser mayor del obligado
  16.             if (count($this->_must_contain) > count ($this->_can_contain))
  17.                 throw new \Exception ("El universo de lo posible de ser mayor del obligado");  
  18.                 //return false;
  19.         }  
  20.          
  21.         // todo elemento en MUST debe estar en CAN
  22.         foreach ($this->_must_contain as $must){
  23.             #$must_name = $must->getElementName();
  24.                    
  25.             $found = false;
  26.             foreach ($this->_can_contain as $can){
  27.                 if ($can->compareTo($must)>=0) // >= ó ==
  28.                     $found = true;            
  29.             }  
  30.             if (!$found)
  31.                 throw new \Exception ("Todo elemento en MUST debe estar en CAN");
  32.                 //return false;
  33.         }
  34.          
  35.        
  36.        
  37.         if (!empty($this->_secuence))
  38.         {      
  39.             // tags que DEBEN obligadamente estar
  40.             foreach ($this->_must_contain as $tag){
  41.            
  42.                 if (!$this->find($tag))
  43.                     throw new \Exception ("Hay tags que DEBEN obligadamente estar");
  44.                     //return false;  
  45.  
  46.                 $this->rewind();
  47.             }
  48.        
  49.  
  50.             // tags que obligadamente *no* DEBEN estar        
  51.             foreach ($this->_must_not_contain as $tag){
  52.            
  53.                 if ($this->find($tag))
  54.                     throw new \Exception ("Hay tags que obligadamente *no* DEBEN estar");
  55.                     //return false;  
  56.  
  57.                 $this->rewind();
  58.             }
  59.         }else
  60.             return null;
  61.  
  62.         // por que no la captura ?
  63.         }catch (Exception $e){
  64.             echo 'Error de chequeo: ', $e->getMessage(), "\n";
  65.             return false;
  66.         }
  67.  
  68.         return true;
  69.     }
__________________
Salu2!