Exception: Dentaku::ArgumentError

Inherits:
ArgumentError
  • Object
show all
Includes:
Error
Defined in:
lib/dentaku/exceptions.rb

Constant Summary collapse

VALID_REASONS =
%i[
  incompatible_type
  invalid_operator
  invalid_value
  too_few_arguments
  wrong_number_of_arguments
].freeze

Instance Attribute Summary collapse

Attributes included from Error

#assigned_to

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, **meta) ⇒ ArgumentError

Returns a new instance of ArgumentError.



148
149
150
151
152
# File 'lib/dentaku/exceptions.rb', line 148

def initialize(reason, **meta)
  @reason = reason
  @meta = meta
  super(default_message)
end

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



146
147
148
# File 'lib/dentaku/exceptions.rb', line 146

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



146
147
148
# File 'lib/dentaku/exceptions.rb', line 146

def reason
  @reason
end

Class Method Details

.for(reason, **meta) ⇒ Object



164
165
166
167
168
169
170
# File 'lib/dentaku/exceptions.rb', line 164

def self.for(reason, **meta)
  unless VALID_REASONS.include?(reason)
    raise ::ArgumentError, "Unhandled #{reason}"
  end

  new(reason, **meta)
end