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

Rescue unexpected parser errors and display source #128

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented Mar 10, 2022

Sometimes the parser crashes because of some RBI input we never though about.

This happened today and had to figure which one of the 400,000 lines in the input RBI file was the culprit.

To make easier to debug, this PR proposes to catch all unexpected errors originating from the parser and display this:

##################################
### RBI::Parser internal error ###
##################################

There was an internal parser error while processing this source.
Please open an issue at https://github.com/Shopify/rbi/issues/new.

Error: undefined method `children' for nil:NilClass while parsing `test.rbi:4:2-6:19`:
~~~
  sig {params(
  )
  .returns(Return)}
  def call()
~~~

##################################

Shopify/rbi/lib/rbi/parser.rb:663:in `visit_send': undefined method `children' for nil:NilClass (NoMethodError)
Shopify/rbi/lib/rbi/parser.rb:113:in `rescue in parse': undefined method `children' for nil:NilClass (RBI::UnexpectedParserError)

@Morriar Morriar added the enhancement New feature or request label Mar 10, 2022
@Morriar Morriar requested a review from a team March 10, 2022 21:44
@Morriar Morriar self-assigned this Mar 10, 2022
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar merged commit d1d27e0 into main Mar 10, 2022
@Morriar Morriar deleted the at-unexpected-parser-error branch March 10, 2022 22:05
@shopify-shipit shopify-shipit bot temporarily deployed to production March 15, 2022 13:30 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants