Sha256: 6541777352ade57ac1e3007f5576a43a8447c51d1c7d06350e2327c16f38a3ff

Contents?: true

Size: 756 Bytes

Versions: 31

Compression:

Stored size: 756 Bytes

Contents

module Alephant
  module Broker
    class ErrorComponent
      attr_reader :batch_id, :content, :id, :options, :status

      def initialize(meta, status, exception)
        @batch_id = meta.batch_id
        @status   = status
        @content  = content_for exception
        @id       = meta.id
        @options  = {}
      end

      def content_type
        headers['Content-Type']
      end

      def headers
        {
          'Content-Type' => 'text/plain'
        }
      end

      private

      def content_for(exception)
        "#{exception.message}".tap do |msg|
          msg << "\n#{exception.backtrace.join('\n')}" if debug?
        end
      end

      def debug?
        Broker.config.fetch('debug', false)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
alephant-broker-3.13.0 lib/alephant/broker/error_component.rb
alephant-broker-3.12.0 lib/alephant/broker/error_component.rb
alephant-broker-3.11.0 lib/alephant/broker/error_component.rb
alephant-broker-3.10.2 lib/alephant/broker/error_component.rb
alephant-broker-3.10.1 lib/alephant/broker/error_component.rb
alephant-broker-3.10.0 lib/alephant/broker/error_component.rb
alephant-broker-3.9.2 lib/alephant/broker/error_component.rb
alephant-broker-3.9.1 lib/alephant/broker/error_component.rb
alephant-broker-3.9.0 lib/alephant/broker/error_component.rb
alephant-broker-3.8.0 lib/alephant/broker/error_component.rb
alephant-broker-3.7.1 lib/alephant/broker/error_component.rb
alephant-broker-3.7.0 lib/alephant/broker/error_component.rb
alephant-broker-3.6.1 lib/alephant/broker/error_component.rb
alephant-broker-3.6.0 lib/alephant/broker/error_component.rb
alephant-broker-3.5.5 lib/alephant/broker/error_component.rb
alephant-broker-3.5.4 lib/alephant/broker/error_component.rb
alephant-broker-3.5.3 lib/alephant/broker/error_component.rb
alephant-broker-3.5.2 lib/alephant/broker/error_component.rb
alephant-broker-3.5.1 lib/alephant/broker/error_component.rb
alephant-broker-3.5.0 lib/alephant/broker/error_component.rb