def perform(action, workitem)
      @action, @workitem = action, workitem
      send(action)
      write_output('') # Triggers any remaining buffered output to be sent
      run_callbacks
    rescue MaestroDev::Plugin::PluginError => e
      write_output('') # Triggers any remaining buffered output to be sent
      set_error(e.message)
    rescue Exception => e
      write_output('') # Triggers any remaining buffered output to be sent
      lowerstack = e.backtrace.find_index(caller[0])
      stack = lowerstack ? e.backtrace[0..lowerstack - 1] : e.backtrace
      msg = "Unexpected error executing task: #{e.class} #{e} at\n" + stack.join("\n")
      Maestro.log.warn("#{msg}\nFull stack:\n" + e.backtrace.join("\n"))

      # Let user-supplied exception handler do its thing
      handle_exception(e)
      set_error(msg)
    ensure
      # Older agents expected this method to *maybe* return something
      # .. something that no longer exists, but if we return anything
      # it will be *wrong* :P
      return nil
    end
def perform(action, workitem)
      @action, @workitem = action, workitem
      send(action)
      write_output('') # Triggers any remaining buffered output to be sent
      run_callbacks
    rescue MaestroDev::Plugin::PluginError => e
      write_output('') # Triggers any remaining buffered output to be sent
      set_error(e.message)
    rescue Exception => e
      write_output('') # Triggers any remaining buffered output to be sent
      lowerstack = e.backtrace.find_index(caller[0])
      stack = lowerstack ? e.backtrace[0..lowerstack - 1] : e.backtrace
      msg = "Unexpected error executing task: #{e.class} #{e} at\n" + stack.join("\n")
      Maestro.log.warn("#{msg}\nFull stack:\n" + e.backtrace.join("\n"))

      # Let user-supplied exception handler do its thing
      handle_exception(e)
      set_error(msg)
    ensure
      # Older agents expected this method to *maybe* return something
      # .. something that no longer exists, but if we return anything
      # it will be *wrong* :P
      return nil
    end
Perform the specified action with the provided workitem. Invokes the method specified by the action parameter.