Sha256: c93e567d78e14f8210287067177472b558dcae9c51c6d5c39fb1dcd79b9eb9b6

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 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

2 entries across 2 versions & 1 rubygems

Version Path
loaf-0.10.0 lib/loaf/errors.rb
loaf-0.9.0 lib/loaf/errors.rb