ConradIrwin / pry-rescue

Start a pry session whenever something goes wrong.
MIT License
848 stars 49 forks source link

Bug: doesn't work with `rails runner` #119

Open swanson opened 3 years ago

swanson commented 3 years ago

I often use rails runner $PATH_TO_SCRIPT to run import scripts or other miscellaneous tasks (similar to rake tasks). But since the runner command is only running the script, the pry-rescue middleware isn't involved and no exceptions get rescued when doing rescue rails runner $PATH_TO_SCRIPT.

swanson commented 3 years ago

Workaround: passing -i flag will at least catch the exceptions, but not ideal since it pulls up the session regardless of if there was an error or not.

bundle exec rescue -i bin/rails runner db/import.rb