code: func (worker *Worker) taskFailed(signature *tasks.Signature, taskErr error) error {
  	// Update task state to FAILURE
  	if err := worker.server.GetBackend().SetStateFailure(signature, taskErr.Error()); err != nil {
  		return fmt.Errorf("Set state to 'failure' for task %s returned error: %s", signature.UUID, err)
  	}
  
  	if worker.errorHandler != nil {
  		worker.errorHandler(taskErr)
  	} else {
  		log.ERROR.Printf("Failed processing task %s. Error = %v", signature.UUID, taskErr)
  	}
  
  	// Trigger error callbacks
  	for _, errorTask := range signature.OnError {
  		// Pass error as a first argument to error callbacks
  		args := append([]tasks.Arg{{
  			Type:  "string",
  			Value: taskErr.Error(),
  		}}, errorTask.Args...)
  		errorTask.Args = args
  		worker.server.SendTask(errorTask)
  	}
  
  	return nil
  }
docs: // taskFailed updates the task state and triggers error callbacks