Exception: Dentaku::ParseError

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

Constant Summary collapse

VALID_REASONS =
%i[
  node_invalid too_few_operands too_many_operands undefined_function
  unprocessed_token unknown_case_token unbalanced_bracket
  unbalanced_parenthesis unknown_grouping_token not_implemented_token_category
  invalid_statement
].freeze

Instance Attribute Summary collapse

Attributes included from Error

#assigned_to

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, **meta) ⇒ ParseError

Returns a new instance of ParseError.



43
44
45
46
47
# File 'lib/dentaku/exceptions.rb', line 43

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



41
42
43
# File 'lib/dentaku/exceptions.rb', line 41

def meta
  @meta
end

#reasonObject (readonly)

Returns the value of attribute reason.



41
42
43
# File 'lib/dentaku/exceptions.rb', line 41

def reason
  @reason
end

Class Method Details

.for(reason, **meta) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/dentaku/exceptions.rb', line 58

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

  new(reason, **meta)
end