public function onRequestTerminate() 
  {
    // lets see if there were unhandled fatal errors
    $lasterror=error_get_last();
    if(!is_null($lasterror)){
      if($lasterror['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)){
        // fatal error occured
        // increase memory limit so we we can at least complete our error handling (in case it was Allowed memory size exhausted)
        // (adding 1MB, unless already unlimited)
        $memlim=Web2All_PHP_INI::getBytes(ini_get('memory_limit'));
        if($memlim!=-1){
          ini_set('memory_limit',$memlim+1000000);
        }
        // then add this error to the observers
        $error = Web2All_Manager_Error::getInstance();
        $exception = new Web2All_Manager_TriggerException($lasterror['type'], $lasterror['message'], $lasterror['file'], $lasterror['line'], array());
        if ($error) {
          $error->setState($exception,$lasterror['type']);
        }
      }
    }
  }