Sha256: 23faeedcccfbb51e5146c307fd3a9cd85a55e970b42467fae76db76922b821f0

Contents?: true

Size: 756 Bytes

Versions: 1

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.to_s.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

1 entries across 1 versions & 1 rubygems

Version Path
alephant-broker-3.14.0 lib/alephant/broker/error_component.rb