Sha256: 968dbc05bf625597a48d9030dc29322b23cac1e734101af5fe469d871349ecd1

Contents?: true

Size: 811 Bytes

Versions: 20

Compression:

Stored size: 811 Bytes

Contents

require 'i18n'

module Scorpion
  class Error < StandardError

    private
      def translate( key, args = {} )
        I18n.translate key, args.merge( scope: [:scorpion,:errors,:messages] )
      end
  end

  class UnsuccessfulHunt < Error
    attr_reader :contract
    attr_reader :traits

    def initialize( contract, traits = nil )
      @contract = contract
      @traits   = traits

      super translate( :unsuccessful_hunt, contract: contract, traits: traits )
    end
  end

  class ArityMismatch < Error
    def initialize( block, expected_count )
      super translate( :arity_mismatch, expected: expected_count, actual: block.arity )
    end
  end

  class BuilderRequiredError < Error
    def initialize( message = nil )
      super ( message || translate( :builder_required ) )
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
scorpion-ioc-0.5.20 lib/scorpion/error.rb
scorpion-ioc-0.5.19 lib/scorpion/error.rb
scorpion-ioc-0.5.18 lib/scorpion/error.rb
scorpion-ioc-0.5.17 lib/scorpion/error.rb
scorpion-ioc-0.5.16 lib/scorpion/error.rb
scorpion-ioc-0.5.15 lib/scorpion/error.rb
scorpion-ioc-0.5.14 lib/scorpion/error.rb
scorpion-ioc-0.5.13 lib/scorpion/error.rb
scorpion-ioc-0.5.12 lib/scorpion/error.rb
scorpion-ioc-0.5.11 lib/scorpion/error.rb
scorpion-ioc-0.5.10 lib/scorpion/error.rb
scorpion-ioc-0.5.9 lib/scorpion/error.rb
scorpion-ioc-0.5.8 lib/scorpion/error.rb
scorpion-ioc-0.5.7 lib/scorpion/error.rb
scorpion-ioc-0.5.6 lib/scorpion/error.rb
scorpion-ioc-0.5.5 lib/scorpion/error.rb
scorpion-ioc-0.5.4 lib/scorpion/error.rb
scorpion-ioc-0.5.2 lib/scorpion/error.rb
scorpion-ioc-0.5.1 lib/scorpion/error.rb
scorpion-ioc-0.5.0 lib/scorpion/error.rb