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

Get original exception in case of re-raise #106

Merged
merged 3 commits into from
May 8, 2017
Merged

Get original exception in case of re-raise #106

merged 3 commits into from
May 8, 2017

Conversation

epergo
Copy link
Collaborator

@epergo epergo commented May 7, 2017

Hello!

I've recently discovered this gem and I love it! But unfortunately when I was testing it out in my Rails project I got to the point where I faced an error in one of my views and after checking the project's issues I found #89 :(

After learning about Rails Template::Error class I have found that the original exception is stored in its attribute cause so in order to cd to that exception I have modified your cd-cause method to check if there is a cause exception and in that case cd there.

Rails source about what I am talking about:
https://github.com/rails/rails/blob/master/actionview/lib/action_view/template/error.rb#L68

Tests are passing and I have tested against @yar sample project too, https://github.com/yar/p-r-test

Now you can cd-cause correctly to the root of the problem and see what is happening

(@yar post #89 (comment))

@ConradIrwin
Copy link
Owner

@epergo Any chance of a test? :D

epergo added 2 commits May 8, 2017 09:33
* ActionView captures exceptions when compiling templates and launches
  its custom error, ActionView::Template::Error, this re-raising makes
  the exception to loose its context and therefore pry-rescue don't
  know how to `cd-cause` to the root of the problem.
@epergo
Copy link
Collaborator Author

epergo commented May 8, 2017

Here you have!

Without the fix this tests fails because when you cd-cause PryRescue enter exception context with exception e2 (TemplateError) again, instead of e1 RuntimeError(original)

@ConradIrwin ConradIrwin merged commit c90e9a1 into ConradIrwin:master May 8, 2017
@ConradIrwin
Copy link
Owner

Thanks!

@ConradIrwin
Copy link
Owner

P.S. I've added you as a collaborator on this repo, feel free to go wild :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants