Exception: Dentaku::ArgumentError

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

Constant Summary collapse

VALID_REASONS =
%i[
  invalid_operator invalid_value too_few_arguments
  too_much_arguments incompatible_type
].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.



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

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



84
85
86
# File 'lib/dentaku/exceptions.rb', line 84

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



84
85
86
# File 'lib/dentaku/exceptions.rb', line 84

def reason
  @reason
end

#recipient_variableObject

Returns the value of attribute recipient_variable.



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

def recipient_variable
  @recipient_variable
end

Class Method Details

.for(reason, **meta) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/dentaku/exceptions.rb', line 99

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

  new(reason, **meta)
end