<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Exception</title>
  </head>
  <body>

<%
  sections_content = @sections.map do |section|
    begin
      summary = render(section).strip
      unless summary.blank?
        title = render("title", :title => section).strip
        [title, summary]
      end

    rescue Exception => e
      title = render("title", :title => section).strip
      summary = ["ERROR: Failed to generate exception summary:", [e.class.to_s, e.message].join(": "), e.backtrace && e.backtrace.join("\n")].compact.join("\n\n")

      [title, summary]
    end
  end
%>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr><td align="center" valign="top">
    <table width="650" border="0" cellpadding="0" cellspacing="20">
      <tr>
        <td style="padding: 10px; border: 1px solid #eed3d7; background-color: #f2dede">
          <h3 style="color: #b94a48">
            <%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in background at <%= @timestamp %> :
          </h3>
          <p style="color: #b94a48"><%= @exception.message %></p>
          <pre style="font-size: 12px; padding: 5px; background-color:#f5f5f5">
<%= @backtrace.first %>
          </pre>
        </td>
      </tr>
      <% sections_content.each do |title, summary| %>
        <tr>
          <td style="border-bottom: 1px solid #eeeeee;"><%= raw title %></td>
        </tr>
        <tr>
          <td><%= raw summary %></td>
        </tr>
      <% end %>
    </table>
  </td></tr>
</table>
  </body>
</html>
