Reputation: 933
I need a way to catch and log exceptions from Rails views.
Strangly enough, a method in the controller does not get exception, if it happens inside <% %> erb block
Upvotes: 2
Views: 2458
Reputation: 933
I decided, that the most reliable way is to add a rescue block INSIDE any erb file:
<% begin %>
... ERB file here: html, html, some scripts, HTML
<% rescue => e%>
<% Mylogger.ErrorERB 'Exception in erb:', e %>
<% end %>
Upvotes: 3