Exception: Dentaku::TokenizerError

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

Constant Summary collapse

VALID_REASONS =
%i[
  parse_error too_many_opening_parentheses too_many_closing_parentheses
  unexpected_zero_width_match
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, **meta) ⇒ TokenizerError

Returns a new instance of TokenizerError.



54
55
56
57
# File 'lib/dentaku/exceptions.rb', line 54

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



52
53
54
# File 'lib/dentaku/exceptions.rb', line 52

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



52
53
54
# File 'lib/dentaku/exceptions.rb', line 52

def reason
  @reason
end

Class Method Details

.for(reason, **meta) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/dentaku/exceptions.rb', line 66

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

  new(reason, **meta)
end