Exception: Rosette::Core::SyntaxError
- Inherits:
-
StandardError
- Object
- StandardError
- Rosette::Core::SyntaxError
- 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
-
#language ⇒ Symbol
readonly
The language that the text the parser attempted to parse was in when this error was generated.
-
#message ⇒ String
(also: #to_s)
readonly
A string representation of this error which combines both the original message as well as the language.
-
#original_exception ⇒ Exception
readonly
The original exception, probably from a parser of some kind.
Instance Method Summary collapse
-
#initialize(msg, original_exception, language) ⇒ SyntaxError
constructor
Creates a new syntax error object.
Constructor Details
#initialize(msg, original_exception, language) ⇒ SyntaxError
Creates a new syntax error object.
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
#language ⇒ Symbol (readonly)
Returns 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} (#{language})" end alias :to_s :message end |
#message ⇒ String (readonly) Also known as: to_s
A string representation of this error which combines both the original message as well as the language.
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} (#{language})" end alias :to_s :message end |
#original_exception ⇒ Exception (readonly)
Returns 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} (#{language})" end alias :to_s :message end |