Sha256: 8a9b36d70eb2116e00126d197686c707f5cf7e557c27942280bfe96a5cb00ef2

Contents?: true

Size: 1.15 KB

Versions: 97

Compression:

Stored size: 1.15 KB

Contents

module CC
  module Analyzer
    class RaisingContainerListener < ContainerListener
      def initialize(failure_ex, timeout_ex = nil, maximum_output_ex = nil)
        @failure_ex = failure_ex
        @timeout_ex = timeout_ex || failure_ex
        @maximum_output_ex = maximum_output_ex || failure_ex
      end

      def finished(engine, _details, result)
        if result.timed_out?
          message = "engine #{engine.name} ran for #{result.duration / 1000}"
          message << " seconds and was killed"
          raise timeout_ex.new(message, engine.name)
        elsif result.maximum_output_exceeded?
          message = "engine #{engine.name} produced too much output"
          message << " (#{result.output_byte_count} bytes)"
          raise maximum_output_ex.new(message, engine.name)
        elsif result.exit_status.nonzero?
          message = "engine #{engine.name} failed"
          message << " with status #{result.exit_status}"
          message << " and stderr \n#{result.stderr}"
          raise failure_ex.new(message, engine.name)
        end
      end

      private

      attr_reader :failure_ex, :timeout_ex, :maximum_output_ex
    end
  end
end

Version data entries

97 entries across 97 versions & 2 rubygems

Version Path
codeclimate-0.85.27 lib/cc/analyzer/raising_container_listener.rb
codeclimate-0.85.26 lib/cc/analyzer/raising_container_listener.rb
codeclimate-0.85.25 lib/cc/analyzer/raising_container_listener.rb
codeclimate-0.85.24 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.54 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.53 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.52 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.51 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.50 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.49 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.48 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.47 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.46 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.45 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.44 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.43 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.42 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.41 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.40 lib/cc/analyzer/raising_container_listener.rb
codeclimate-fede-0.85.39 lib/cc/analyzer/raising_container_listener.rb