Sha256: c143f14f232a2685a2f45ca7ee100acd236eece9fb5ebd0c3218f550464a85f5

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

module MiniCamel
  class ExchangeError
    include Virtus.value_object

    values do
      attribute :error_class, Class, reader: :private
      attribute :message, String, reader: :private
      attribute :details, Dto, reader: :private
    end

    attribute :backtrace, Array, default: []

    def on(check_error_class)
      yield message, details if check_error_class == error_class

      self
    end

    # This is just a helper method.
    # Do not use it in production code!
    def raise!
      raise ReRaisedError.new(message, error_class)
    end

    def as_json(options = {})
      {error_class: error_class.name, message: message, details: details}.as_json(options)
    end

    private

    def details
      @details ||= Dto.empty
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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