class SyntaxSuggest::RipperErrors - Documentation for Ruby 4.0
Description: class SyntaxSuggest::RipperErrors: Capture parse errors from Ripper Prism returns the errors with their messages, but Ripper does not. To get them we must make a custom subclass.
Keywords: ruby,class,SyntaxSuggest::RipperErrors

🔍

No recent searches

# class SyntaxSuggest::RipperErrors

`Capture` parse errors from `Ripper`

`Prism` returns the errors with their messages, but `Ripper` does not. To get them we must make a custom subclass.

Example:

    puts RipperErrors.new(" def foo").call.errors
    # => ["syntax error, unexpected end-of-input, expecting ';' or '\\n'"]

### Attributes

errors [R]

### Public Instance Methods

call ()
Source

    # File lib/syntax_suggest/ripper_errors.rb, line 30
    def call
      @run_once ||= begin
        @errors = []
        parse
        true
      end
      self
    end

compile_error (msg)
Alias for: on_parse_error
on_alias_error (msg)
Alias for: on_parse_error
on_assign_error (msg)
Alias for: on_parse_error
on_class_name_error (msg)
Alias for: on_parse_error
on_param_error (msg)
Alias for: on_parse_error
on_parse_error (msg)
Source

    # File lib/syntax_suggest/ripper_errors.rb, line 19
    def on_parse_error(msg)
      @errors ||= []
      @errors << msg
    end

Comes from ripper, called on every parse error, msg is a string

Also aliased as: on_alias_error, on_assign_error, on_class_name_error, on_param_error, compile_error