Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
jm opened this Issue · 2 comments

3 participants

@jm
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: https://github.com/pry/pry/blob/master/lib/pry/pry_instance.rb#L308

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. :)

@banister
Owner

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 https://gist.github.com/8992b265c63ff966d0d3

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
jm commented

That's perfect! :+1:

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.