Exception: Rosette::Core::ExtractionSyntaxError

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

Overview

Represents a generic syntax error generated by one of Rosette's extractors. Since extractors parse source code and other well-defined text formats, there's always the possibility that these formats will contain syntax errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, original_exception, language, file, commit_id) ⇒ ExtractionSyntaxError

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.

  • file (String)

    The file that was being parsed when the error was generated.

  • commit_id (String)

    The commit id that contained the file that was being parsed when the error was generated.


72
73
74
75
76
77
78
79
# File 'lib/rosette/core/errors.rb', line 72

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

Instance Attribute Details

#commit_idString (readonly)

Returns the commit id that contained the file that was being parsed when the error was generated.

Returns:

  • (String)

    the commit id that contained the file that was being parsed when the error was generated.


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rosette/core/errors.rb', line 59

class ExtractionSyntaxError < StandardError
  attr_reader :original_exception, :language, :file, :commit_id

  # 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.
  # @param [String] file The file that was being parsed when the error
  #   was generated.
  # @param [String] commit_id The commit id that contained the file that
  #   was being parsed when the error was generated.
  def initialize(msg, original_exception, language, file, commit_id)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
    @file = file
    @commit_id = commit_id
  end

  # A string representation of this error which includes the original
  # message, the source language, the file, and the commit id.
  #
  # @return [String]
  def message
    "#{@message}: #{original_exception.message} (#{language}) in #{file} at #{commit_id}"
  end

  alias :to_s :message
end

#fileString (readonly)

Returns the file that was being parsed when the error was generated.

Returns:

  • (String)

    the file that was being parsed when the error was generated.


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rosette/core/errors.rb', line 59

class ExtractionSyntaxError < StandardError
  attr_reader :original_exception, :language, :file, :commit_id

  # 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.
  # @param [String] file The file that was being parsed when the error
  #   was generated.
  # @param [String] commit_id The commit id that contained the file that
  #   was being parsed when the error was generated.
  def initialize(msg, original_exception, language, file, commit_id)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
    @file = file
    @commit_id = commit_id
  end

  # A string representation of this error which includes the original
  # message, the source language, the file, and the commit id.
  #
  # @return [String]
  def message
    "#{@message}: #{original_exception.message} (#{language}) in #{file} at #{commit_id}"
  end

  alias :to_s :message
end

#languageSymbol (readonly)

Returns the source code language.

Returns:

  • (Symbol)

    the source code language.


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rosette/core/errors.rb', line 59

class ExtractionSyntaxError < StandardError
  attr_reader :original_exception, :language, :file, :commit_id

  # 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.
  # @param [String] file The file that was being parsed when the error
  #   was generated.
  # @param [String] commit_id The commit id that contained the file that
  #   was being parsed when the error was generated.
  def initialize(msg, original_exception, language, file, commit_id)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
    @file = file
    @commit_id = commit_id
  end

  # A string representation of this error which includes the original
  # message, the source language, the file, and the commit id.
  #
  # @return [String]
  def message
    "#{@message}: #{original_exception.message} (#{language}) in #{file} at #{commit_id}"
  end

  alias :to_s :message
end

#original_exceptionException (readonly)

Returns the original error from the parser or some such.

Returns:

  • (Exception)

    the original error from the parser or some such.


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rosette/core/errors.rb', line 59

class ExtractionSyntaxError < StandardError
  attr_reader :original_exception, :language, :file, :commit_id

  # 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.
  # @param [String] file The file that was being parsed when the error
  #   was generated.
  # @param [String] commit_id The commit id that contained the file that
  #   was being parsed when the error was generated.
  def initialize(msg, original_exception, language, file, commit_id)
    super(msg)
    @message = msg
    @original_exception = original_exception
    @language = language
    @file = file
    @commit_id = commit_id
  end

  # A string representation of this error which includes the original
  # message, the source language, the file, and the commit id.
  #
  # @return [String]
  def message
    "#{@message}: #{original_exception.message} (#{language}) in #{file} at #{commit_id}"
  end

  alias :to_s :message
end

Instance Method Details

#messageString Also known as: to_s

A string representation of this error which includes the original message, the source language, the file, and the commit id.

Returns:

  • (String)

85
86
87
# File 'lib/rosette/core/errors.rb', line 85

def message
  "#{@message}: #{original_exception.message} (#{language}) in #{file} at #{commit_id}"
end