Sha256: 615fe640dc8443b1932a74ff9267e4024374e779786862fef5a8a73d638bb069

Contents?: true

Size: 643 Bytes

Versions: 16

Compression:

Stored size: 643 Bytes

Contents

require "i18n"

module Shamu

  # A generic error class for problems in the shamu library.
  class Error < StandardError
    private

      def translation_scope
        [ :shamu, :errors ]
      end

      def translate( key, **args )
        I18n.translate key, args.merge( scope: translation_scope )
      end
  end

  # The resource was not found.
  class NotFoundError < Error
    def initialize( message = :not_found )
      super translate( message )
    end
  end

  # The method is not implemented.
  class NotImplementedError < Error
    def initialize( message = :not_implemented )
      super translate( message )
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shamu-0.0.21 lib/shamu/error.rb
shamu-0.0.20 lib/shamu/error.rb
shamu-0.0.19 lib/shamu/error.rb
shamu-0.0.18 lib/shamu/error.rb
shamu-0.0.17 lib/shamu/error.rb
shamu-0.0.15 lib/shamu/error.rb
shamu-0.0.14 lib/shamu/error.rb
shamu-0.0.13 lib/shamu/error.rb
shamu-0.0.11 lib/shamu/error.rb
shamu-0.0.9 lib/shamu/error.rb
shamu-0.0.8 lib/shamu/error.rb
shamu-0.0.7 lib/shamu/error.rb
shamu-0.0.5 lib/shamu/error.rb
shamu-0.0.4 lib/shamu/error.rb
shamu-0.0.3 lib/shamu/error.rb
shamu-0.0.2 lib/shamu/error.rb