Sha256: f19ecef9afafef51d4a9100e28d256a313b5693caf0733381f9d7d792e5d66a7
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
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 class ContractMismatchError < Error def initialize( message_or_module = nil, initializer_attr = nil, injected_attr = nil ) if message_or_module.is_a?( Module ) super translate( :contract_mismatch, module: message_or_module, name: initializer_attr.name, from: initializer_attr.contract, to: injected_attr.contract ) else super ( message || translate( :contract_mismatch ) ) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems