Ruby on Rails Saturday, November 21, 2015

You are fantastic. This previously worked in 1.9, so I'm assuming something changed so that SyntaxError is no longer under StandardError. Problem solved, thank you for your help.

=Ryan

On Monday, October 19, 2015 at 4:04:14 AM UTC-5, Andy Ogzewalla wrote:
By default rescue only matches StandardError. If you are getting another type of Exception then your usage of rescue will not be sufficient to handle it. You will need to use the multiline form of begin/rescue.

```
begin
  ActionView::Template.new("Test <% if Crash %>", "inline template", handler, :locals => {}).render("Test2",{})
rescue Exception  # You should replace Exception with a more specific class or classes if possible.
  false
end

On Sunday, October 18, 2015 at 4:17:24 PM UTC-5, kopf1988 wrote:
I am attempting to debug some complicated inline templates, because they are generated dynamically with the complicated way this program works.

However when doing render inline: "Template here" rescue false, an error is still thrown if there's an error in the Template.

I tried this in IRB and it's very weird!
ActionView::Template.new("Test <% if Crash %>", "inline template", handler, :locals => {}).render("Test2",{}) rescue false

This returns an error, even though we would expect the Rescue to rescue us from the bad code in the inline template. This worked in an old version of Rails.

Any ideas?

Breaking out into multiple lines also didn't help
begin
ActionView::Template.new("Test <% if Crash %>", "inline template", handler, :locals => {}).render("Test2",{})
rescue
false
end

Still has an error.

=Ryan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2c9fa092-c7ba-4d91-9d30-f88e4f8b11c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment