<?php
class FileNotWriteableException extends Exception
{
    public function 
__construct$file )
    {
        
parent::__construct(
            
"File not writeable <$file>"
        
);
}

function 
writeToFile$file$content )
{
    if ( ( 
$f fopen$file"w" ) ) === false )
    {
        throw new 
FileNotWritableException(
            
$file
        
);
    }
    
// ...
}

try
{
    
writeToFile"/tmp/foo""99 klingons..." );
}
catch ( 
FileNotWriteableException $e )
{
    
// handle error...
}
?>


<?php
// ...

function handleErrorException $e )
{
    
// handle error...
}

set_exception_handler"handleError" );

writeToFile"/tmp/foo" );
?>