Sha256: fda73115d05652c527888a8f5e88443965e4d91597ebd16f22858a55cf5b203a

Contents?: true

Size: 729 Bytes

Versions: 2

Compression:

Stored size: 729 Bytes

Contents

# encoding: utf-8

module Loaf #:nodoc:

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

    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.4.0 lib/loaf/errors.rb
loaf-0.3.0 lib/loaf/errors.rb