Skip to content

Loading…

Exception on tab complete not caught #632

Closed
joliss opened this Issue · 4 comments

4 participants

@joliss

Pry crashed when I pressed tab:

[7] pry(main)> Forgery(:name)Error: unmatched close parenthesis: /^:name)/
FATAL: Pry failed to get user input using `Readline`.
To fix this you may be able to pass input and output file descriptors to pry directly. e.g.
  Pry.config.input = STDIN
  Pry.config.output = STDOUT
  binding.pry

I'm thinking there could be a catch-all exception handler around the tab completion code that stops it from crashing.

@banister
pry member

I agree, broken tab completion should never cause a crash, thanks :)

@YorickPeterse
pry member

I believe this issue (or at least similar ones) were already fixed in ea016d8 and following commits.

@joliss

Great, so that fixes this specific crash.

How do you feel about wrapping the entire tab completion code in an exception handler (so pry can't crash from it)?

@YorickPeterse
pry member

That sounds like a plan. However, and this is something that bothered by before, I want it to (optionally) display a stack trace. When I tried to fix this issue the error message displayed by Pry wasn't particular useful and I had to manually insert code to get the stack trace to show up.

Because of this I propose the introduction of a new option: --verbose. When set Pry error messages would display stack traces and other information that might be useful when debugging an issue.

@ConradIrwin ConradIrwin added a commit that closed this issue
@ConradIrwin ConradIrwin Be more careful exception handling in Readline [Fixes #632, #605]
Firstly wrap the entire completion_proc in a begin/rescue/end so that
even if something we're not expecting goes wrong, we don't fail.

Secondly, only throw the user out of pry if reading from readline fails
five times in a row. This avoids a transient error (like a time-out, or
a failed tab completion) from kicking you out of pry; but also avoids
the infinite looping problem that can happen if the error is not transient.
b5cb8b1
@ghost Unknown pushed a commit that referenced this issue
@ConradIrwin ConradIrwin Be more careful exception handling in Readline [Fixes #632, #605]
Firstly wrap the entire completion_proc in a begin/rescue/end so that
even if something we're not expecting goes wrong, we don't fail.

Secondly, only throw the user out of pry if reading from readline fails
five times in a row. This avoids a transient error (like a time-out, or
a failed tab completion) from kicking you out of pry; but also avoids
the infinite looping problem that can happen if the error is not transient.
62fd85e
@jazzonmymind jazzonmymind pushed a commit that referenced this issue
@ConradIrwin ConradIrwin Be more careful exception handling in Readline [Fixes #632, #605]
Firstly wrap the entire completion_proc in a begin/rescue/end so that
even if something we're not expecting goes wrong, we don't fail.

Secondly, only throw the user out of pry if reading from readline fails
five times in a row. This avoids a transient error (like a time-out, or
a failed tab completion) from kicking you out of pry; but also avoids
the infinite looping problem that can happen if the error is not transient.
65e751c
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.