Sha256: 6a157425ba06987dcee341979a15a9a72c7e298277e46343cc2080a892171257

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

module MiniCamel
  class DefaultErrorHandler
    include Virtus.value_object

    values do
      attribute :registered_errors, Array, default: []
    end

    def call(error, exchange)
      raise error unless error.class.in? registered_errors

      exchange.set_error(assemble_exchange_error(error))
    end

    private

    def assemble_exchange_error(error)
      ExchangeError.new(
        error_class: error.class,
        message: error.message,
        details: Dto.new(details(error)),
        backtrace: error.backtrace || []
      )
    end

    def details(error)
      if error.respond_to?(:internal_errors)
        error.internal_errors
      else
        {}
      end
    end


  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mini_camel-0.5.8 lib/mini_camel/default_error_handler.rb