Exception: Dentaku::TokenizerError

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Attributes included from Error

#assigned_to

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, **meta) ⇒ TokenizerError

Returns a new instance of TokenizerError.



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

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



102
103
104
# File 'lib/dentaku/exceptions.rb', line 102

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



102
103
104
# File 'lib/dentaku/exceptions.rb', line 102

def reason
  @reason
end

Class Method Details

.for(reason, **meta) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/dentaku/exceptions.rb', line 119

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

  new(reason, **meta)
end