Sha256: 962176cb8704150020fba6779588979bc2622c522b835d97a572c09057ae64a5

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

class DevelopmentModePlugin
  def after_response(current_response, _)
    current_response.each do |name, result|
      current_response[name] = result.merge({ "html" => render(name, result) }) if result["error"]
    end
  end

  private

  def render(name, result)
    <<-HTML
      <div style="background-color: #ff5a5f; color: #fff; padding: 12px;">
        <p style="margin: 0">
          <strong>Development Warning!</strong>
          The <code>#{name}</code> component failed to render with Hypernova. Error stack:
        </p>
        <ul style="padding: 0 20px">
          <li>#{stack_trace(result).join("</li><li>")}</li>
        </ul>
      </div>
      #{result["html"]}
    HTML
  end

  def stack_trace(result)
    result["error"]["stack"] || []
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hypernova-1.1.0 lib/hypernova/plugins/development_mode_plugin.rb
hypernova-1.0.3 lib/hypernova/plugins/development_mode_plugin.rb
hypernova-1.0.2 lib/hypernova/plugins/development_mode_plugin.rb