Exception: Dentaku::ArgumentError

Inherits:
ArgumentError
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, **meta) ⇒ ArgumentError

Returns a new instance of ArgumentError.



89
90
91
92
# File 'lib/dentaku/exceptions.rb', line 89

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



86
87
88
# File 'lib/dentaku/exceptions.rb', line 86

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



86
87
88
# File 'lib/dentaku/exceptions.rb', line 86

def reason
  @reason
end

#recipient_variableObject

Returns the value of attribute recipient_variable.



87
88
89
# File 'lib/dentaku/exceptions.rb', line 87

def recipient_variable
  @recipient_variable
end

Class Method Details

.for(reason, **meta) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/dentaku/exceptions.rb', line 104

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

  new(reason, **meta)
end