Exception: Plurimath::Math::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/plurimath/errors/parse_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, type) ⇒ ParseError

Returns a new instance of ParseError.



6
7
8
9
10
# File 'lib/plurimath/errors/parse_error.rb', line 6

def initialize(text, type)
  @text = text
  @type = type.to_sym
  super(@type == :invalid_unitsml ? unitsml_message : parsing_message)
end

Instance Method Details

#generic_partObject



31
32
33
34
35
36
# File 'lib/plurimath/errors/parse_error.rb', line 31

def generic_part
  "    [plurimath] If this is a bug, please report the formula at our issue tracker at:\n    [plurimath] https://github.com/plurimath/plurimath/issues\n  MESSAGE\nend\n".rstrip

#parsing_messageObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/plurimath/errors/parse_error.rb', line 12

def parsing_message
  "    [plurimath] Error: Failed to parse the following formula with type `\#{@type}`.\n    [plurimath] Please first manually validate the formula.\n    \#{generic_part}\n    ---- FORMULA BEGIN ----\n    \#{@text}\n    ---- FORMULA END ----\n  MESSAGE\nend\n"

#unitsml_messageObject



23
24
25
26
27
28
29
# File 'lib/plurimath/errors/parse_error.rb', line 23

def unitsml_message
  "    [plurimath] Invalid formula `\#{@text}`.\n    [plurimath] The use of a variable as an exponent is not valid.\n    \#{generic_part}\n  MESSAGE\nend\n"