Sha256: 4d99aa88c588fe04420fa4b1ef77ce022c4eb116d27b9f35f6e61e295e7bcf93

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

# This file contains all the error classes for this gem.
module DispatchRider
  # The base error class of the gem
  class DispatchRiderError < StandardError
  end

  # The error class for objects not being found
  class NotFound < DispatchRiderError
    def initialize(name)
      super("#{name.to_s} could not be found")
    end
  end

  # The error class for keys not registered in a registrar
  class NotRegistered < DispatchRiderError
    def initialize(name)
      super("#{name.to_s} has not been registered")
    end
  end

  # This error is raised when a queue service depends on an external library, but that is not present
  class AdapterNotFoundError < DispatchRiderError
    def initialize(lib_name, gem_name)
      super("Constant #{lib_name} wasn't found. Please install the #{gem_name} gem")
    end
  end

  # This error is raised when validation fails on an object
  class RecordInvalid < DispatchRiderError
    def initialize(object, error_messages)
      super("#{object.class.name} is not valid because of the following errors : #{error_messages.to_sentence}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-2.2.0 lib/dispatch-rider/errors.rb