Sha256: 40a2c03a9d5a31bbfd7b4c72b43ae5e5bee1a1281ceec480832138c65007113b

Contents?: true

Size: 730 Bytes

Versions: 6

Compression:

Stored size: 730 Bytes

Contents

# frozen_string_literal: true

module Loaf #:nodoc:
  # Default Loaf error for all custom errors.
  #
  class LoafError < StandardError
    BASE_KEY = "loaf.errors"

    def error_message(key, attributes)
      translate(key, attributes)
    end

    def translate(key, options)
      ::I18n.translate("#{BASE_KEY}.#{key}", { :locale => :en }.merge(options))
    end
  end

  # Raised when invalid options are passed to breadcrumbs view renderer.
  #  InvalidOptions.new :name, :crumber, [:crumb]
  #
  class InvalidOptions < LoafError
    def initialize(invalid, valid)
      super(
        error_message("invalid_options",
          { :invalid => invalid, :valid => valid.join(', ') }
        )
      )
    end
  end
end # Loaf

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
loaf-0.8.1 lib/loaf/errors.rb
loaf-0.8.0 lib/loaf/errors.rb
loaf-0.7.0 lib/loaf/errors.rb
loaf-0.6.2 lib/loaf/errors.rb
loaf-0.6.1 lib/loaf/errors.rb
loaf-0.6.0 lib/loaf/errors.rb