Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display all syntax error messages when catching SyntaxException #2117

Merged
merged 1 commit into from Mar 21, 2020

Commits on Mar 21, 2020

  1. Display all syntax error messages when catching SyntaxException

    Previously when catching syntax errors in the REPL, we were only showing
    the last syntax error displayed by the ruby output. However, ruby can
    generate multiple syntax error messages within a single SyntaxException.
    For example, this code generates multiple syntax error messages:
    ```
    $ ruby -e 'puts {"key"=>"val"}.to_json'
    -e:1: syntax error, unexpected =>, expecting '}'
    puts {"key"=>"val"}.to_json
    -e:1: syntax error, unexpected '}', expecting end-of-input
    puts {"key"=>"val"}.to_json
    ```
    We can't predict which error message would be most helpful for the
    consumer - we should show both of them.
    
    This commit modifies the string replacement we're doing when printing
    SyntaxExceptions so any number of syntax error lines will be shown
    correctly.
    
    Issue: pry#2102
    The error message of SyntaxError is different from Ruby's one
    bingram-eab committed Mar 21, 2020
    Copy the full SHA
    f6736d5 View commit details
    Browse the repository at this point in the history