Sha256: 6b2df9338d220d170ab23b1aeabdfe5854f7106e2a1279a47b026c632390a318

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

module Actions
  module RemoteExecution
    module TemplateInvocationProgressLogging
      def template_invocation
        @template_invocation ||= TemplateInvocation.find_by(:run_host_job_task_id => task.id)
      end

      def log_template_invocation_exception(exception)
        template_invocation.template_invocation_events.create!(
          :event_type => 'debug',
          :event => "#{exception.class}: #{exception.message}",
          :timestamp => Time.zone.now
        )
      end

      def with_template_invocation_error_logging
        unless catch(::Dynflow::Action::ERROR) { yield || true }
          log_template_invocation_exception(error.exception)
          throw ::Dynflow::Action::ERROR
        end
      rescue => e # rubocop:disable Style/RescueStandardError
        log_template_invocation_exception(e)
        raise e
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_remote_execution-8.1.1 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-8.1.0 app/lib/actions/remote_execution/template_invocation_progress_logging.rb