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.



78
79
80
81
# File 'lib/dentaku/exceptions.rb', line 78

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



76
77
78
# File 'lib/dentaku/exceptions.rb', line 76

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



76
77
78
# File 'lib/dentaku/exceptions.rb', line 76

def reason
  @reason
end

Class Method Details

.for(reason, **meta) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/dentaku/exceptions.rb', line 90

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

  new(reason, **meta)
end