Sha256: 28ec0348ff93a4b6220c4c01dba7b9ad6ea2c5b9e6eaaf4c4b22ac1d6f0808c5

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

module UNotifier
  class UNotifierError < StandardError; end

  class EmptyLocaleKeyError < UNotifierError
    attr_reader :key

    def initialize(key)
      @key = key
      message = ":locale_key parameter is required for fetching '#{key}' locale"
      super(message)
    end
  end

  class AttributeMissingError < UNotifierError
    attr_reader :key, :attribute

    def initialize(key, attribute)
      @key = key
      @attribute = attribute
      message = "Missing '#{attribute}' attribute for notification '#{key}'"
      super(message)
    end
  end

  class NotificationsConfigNotFoundError < UNotifierError
    attr_reader :path, :absolute_path

    def initialize(path)
      @path = path
      @absolute_path = File.expand_path(@path)
      message = "Configuration file not found at #{@absolute_path}"
      super(message)
    end
  end

  class NotificationNotFoundError < UNotifierError
    attr_reader :key

    def initialize(key)
      @key = key
      message = "Notification with key '#{@key}' not found"
      super(message)
    end
  end

  class UnknownTargetError < UNotifierError
    attr_reader :key, :target

    def initialize(key, target)
      @key = key
      @target = target
      message = "Unknown target '#{@target}' for notification '#{@key}'"
      super(message)
    end
  end

  class UnknownLocaleKeyError < UNotifierError
    attr_reader :key, :locale_key, :options

    def initialize(key, locale_key, options)
      @key = key
      @locale_key = locale_key
      @options = options
      message = "Unkown locale key '#{@locale_key}' for '#{@key}'. Available options: #{@options}"
      super(message)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unotifier-0.5.0 lib/exceptions.rb
unotifier-0.4.1 lib/exceptions.rb
unotifier-0.4.0 lib/exceptions.rb
unotifier-0.3.0 lib/exceptions.rb