Exception: Rosette::Core::SyntaxError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rosette/core/errors.rb

Overview

Represents a generic syntax error that probably occurred when attempting to parse a bit of source code or other well-defined text format.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, original_exception, language) ⇒ SyntaxError

Creates a new syntax error object.

Parameters:

  • msg (String)

    The error message text.

  • original_exception (Exception)

    The original error from the parser or some such.

  • language (Symbol)

    The source code language.


26
27
28
29
30
31
# File 'lib/rosette/core/errors.rb', line 26

def initialize(msg, original_exception, language)
  super(msg)
  @message = msg
  @original_exception = original_exception
  @language = language
end

Instance Attribute Details

#languageSymbol (readonly)

Returns the language that the text the parser attempted to parse was in when this error was generated.

Returns:

  • (Symbol)

    the language that the text the parser attempted to parse was in when this error was generated.


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rosette/core/errors.rb', line 17

class SyntaxError < StandardError
  attr_reader :message, :original_exception, :language

  # Creates a new syntax error object.
  #
  # @param [String] msg The error message text.
  # @param [Exception] original_exception The original error from the
  #   parser or some such.
  # @param [Symbol] language The source code language.
  def initialize(msg, original_exception, language)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
  end

  # A string representation of this error which combines both the original
  # message as well as the language.
  #
  # @return [String]
  def message
    "#{@message} (#{language})"
  end

  alias :to_s :message
end

#messageString (readonly) Also known as: to_s

A string representation of this error which combines both the original message as well as the language.

Returns:

  • (String)

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rosette/core/errors.rb', line 17

class SyntaxError < StandardError
  attr_reader :message, :original_exception, :language

  # Creates a new syntax error object.
  #
  # @param [String] msg The error message text.
  # @param [Exception] original_exception The original error from the
  #   parser or some such.
  # @param [Symbol] language The source code language.
  def initialize(msg, original_exception, language)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
  end

  # A string representation of this error which combines both the original
  # message as well as the language.
  #
  # @return [String]
  def message
    "#{@message} (#{language})"
  end

  alias :to_s :message
end

#original_exceptionException (readonly)

Returns the original exception, probably from a parser of some kind.

Returns:

  • (Exception)

    the original exception, probably from a parser of some kind.


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rosette/core/errors.rb', line 17

class SyntaxError < StandardError
  attr_reader :message, :original_exception, :language

  # Creates a new syntax error object.
  #
  # @param [String] msg The error message text.
  # @param [Exception] original_exception The original error from the
  #   parser or some such.
  # @param [Symbol] language The source code language.
  def initialize(msg, original_exception, language)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
  end

  # A string representation of this error which combines both the original
  # message as well as the language.
  #
  # @return [String]
  def message
    "#{@message} (#{language})"
  end

  alias :to_s :message
end