Sha256: a89a28932277582a1b64bebdd2c3cb4a965ad4c2b67d872354dfb5fa23848d2f

Contents?: true

Size: 777 Bytes

Versions: 10

Compression:

Stored size: 777 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.to_s.tap do |msg|
          msg << "\n#{exception.backtrace.join('\n')}" if debug?
        end
      end

      def debug?
        Broker.config[:debug] || Broker.config["debug"] || false
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
alephant-broker-3.19.1 lib/alephant/broker/error_component.rb
alephant-broker-3.19.0 lib/alephant/broker/error_component.rb
alephant-broker-3.18.0 lib/alephant/broker/error_component.rb
alephant-broker-3.17.0 lib/alephant/broker/error_component.rb
alephant-broker-3.16.2 lib/alephant/broker/error_component.rb
alephant-broker-3.16.1 lib/alephant/broker/error_component.rb
alephant-broker-3.16.0 lib/alephant/broker/error_component.rb
alephant-broker-3.15.2 lib/alephant/broker/error_component.rb
alephant-broker-3.15.1 lib/alephant/broker/error_component.rb
alephant-broker-3.15.0 lib/alephant/broker/error_component.rb