code: func (mtask *managedTask) handleResourceStateChange(resChange resourceStateChange) {
  	// locate the resource
  	res := resChange.resource
  	if !mtask.isResourceFound(res) {
  		seelog.Criticalf("Managed task [%s]: state error; invoked with another task's resource [%s]",
  			mtask.Arn, res.GetName())
  		return
  	}
  
  	status := resChange.nextState
  	err := resChange.err
  	currentKnownStatus := res.GetKnownStatus()
  
  	if status <= currentKnownStatus {
  		seelog.Infof("Managed task [%s]: redundant resource state change. %s to %s, but already %s",
  			mtask.Arn, res.GetName(), res.StatusString(status), res.StatusString(currentKnownStatus))
  		return
  	}
  
  	if err == nil {
  		res.SetKnownStatus(status)
  		mtask.engine.saver.Save()
  		return
  	}
  	seelog.Debugf("Managed task [%s]: error while transitioning resource %s to %s: %v",
  		mtask.Arn, res.GetName(), res.StatusString(status), err)
  	if status == res.SteadyState() {
  		seelog.Errorf("Managed task [%s]: error while creating resource %s, setting the task's desired status to STOPPED",
  			mtask.Arn, res.GetName())
  		mtask.SetDesiredStatus(apitaskstatus.TaskStopped)
  		mtask.Task.SetTerminalReason(res.GetTerminalReason())
  		mtask.engine.saver.Save()
  	}
  }
docs: // handleResourceStateChange attempts to update resource's known status depending on
  // the current status and errors during transition