void ErrorHandle :: WriteError (Error *error_obj )
{
  char         path[256];
  Error        saverr = *error_obj;
  logical      show_errors = NO;
  ProcessInfo *procinfo;
  short        handle;
BEGINSEQ
  if ( error_obj->CheckError() )
  {
    if ( (procinfo = ThreadEntry::GetCurProcInfo()) && 
          procinfo->get_error_file() && *procinfo->get_error_file() )
    {
      strcpy(path,procinfo->get_error_file());
      strcat(strcat(path,"/"),"error.lst");
    }
    else
      strcpy(path,cpath);
    
    show_errors = TestSysVariable("SHOW_ERRORS","YES");
    *error_obj = saverr;
    
    ILock();
    if ( error_obj )
      message.SetData(error_obj);
    
#ifdef __unix__
    if ( (handle = _open (path,
			  (int)(O_RDWR | O_APPEND | O_CREAT ),
			  (S_IREAD | S_IWRITE)                    )) > 0 )
#else  
    if ( (handle = _open (path,
			  (int)(O_WRONLY | O_APPEND  | O_CREAT | O_BINARY ),
			  S_IWRITE                                )) > 0 )
#endif
    {
      _write(handle,&message,sizeof(message));
      _close(handle);
    }
    if ( show_errors )
    {
      if ( !gui_message )
        gui_message = AUTO;        // enable temporaily
      ShowMessage(NULL);
    }
    IUnlock();
    
  }

RECOVER

ENDSEQ

}