Skip to content


Push SyntaxError's over to the configured error handler #774

jm opened this Issue · 2 comments

3 participants

jm commented

Currently, pry will skip the error handler you have configured for SyntaxError's. I get the reason this is done, but it seems that this should be on the exception whitelist rather than special cased in code like this:

I'm trying to write a Pry wrapper for new programmers to experiment with that explains errors to them as they happen, and given that syntax errors are by far the most common errors for them, this was really confusing at first until I looked at the code! Right now I'm hacking the r method, but I'd really, really rather future-proof this thing and not depend on nasty hacks.

If there's a specific reason for this, that's totally cool (and I'd love to hear it!). It was just irritating to have to hack around this bit of code for what I was trying to do. :)

pry member

We special-cased SyntaxError exceptions so we could display them slightly prettier without including backtrace, but there is no reason we can't special-case them inside the exception handler itself.

The following diff moves the special treatment to DEFAULT_EXCEPTION_HANDLER

Let me know if this is OK for you :)

EDIT: unlike in the diff above, the rescue SyntaxError line is removed from the r() method, i'll push a proper commit tomorrow

jm commented

That's perfect! :+1:

@rking rking pushed a commit to rking/pry that referenced this issue
@ConradIrwin ConradIrwin Pass SyntaxErrors to error handler too. [Fixes #774] c4cea7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.