Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/01/2011, 09:20
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Capturar excepcion no funciona

Si lees el Manual:
Cita:
This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.
Es decir si falla regresa false.

Para hacer una versión que soporte excepciones podrías hacer algo así:
Código PHP:
Ver original
  1. function getFileContents($sFile)
  2. {
  3.         $sContents = @file_get_contents($sFile);
  4.         if ($sContents === false) {
  5.                throw new Exception("Unable to read $sFile");
  6.         }
  7.  
  8.         return $sContents;
  9. }

Saludos.