code: func (s *stateTracker) setError(err error) {
  	s.mut.Lock()
  	defer s.mut.Unlock()
  
  	eventData := map[string]interface{}{
  		"folder": s.folderID,
  		"from":   s.current.String(),
  	}
  
  	if err != nil {
  		eventData["error"] = err.Error()
  		s.current = FolderError
  	} else {
  		s.current = FolderIdle
  	}
  
  	eventData["to"] = s.current.String()
  
  	if !s.changed.IsZero() {
  		eventData["duration"] = time.Since(s.changed).Seconds()
  	}
  
  	s.err = err
  	s.changed = time.Now()
  
  	events.Default.Log(events.StateChanged, eventData)
  }
docs: // setError sets the folder state to FolderError with the specified error or
  // to FolderIdle if the error is nil