Sha256: 2b08fdc9e1720d20aabe2826e7c16b567c259f9541eee64de5f46f04d35551fa

Contents?: true

Size: 852 Bytes

Versions: 4

Compression:

Stored size: 852 Bytes

Contents

# Avoid better_errors taking forever to render by ignoring variables larger than
# 10 Kilobytes. Based on https://github.com/charliesome/better_errors/issues/334

if defined?(BetterErrors) && Rails.env.development?
  module BetterErrorsHugeInspectWarning

    def inspect_value(obj)
      inspected = obj.inspect
      if inspected.size > 20_000
        inspected = "Object was too large to inspect (#{inspected.size} bytes)."
      end
      CGI.escapeHTML(inspected)
    rescue NoMethodError
      "<span class='unsupported'>(object doesn't support inspect)</span>"
    rescue Exception
      "<span class='unsupported'>(exception was raised in inspect)</span>"
    end

  end

  BetterErrors.ignored_instance_variables += [:@_request, :@_assigns, :@_controller, :@view_renderer]
  BetterErrors::ErrorPage.prepend(BetterErrorsHugeInspectWarning)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katapult-0.5.0 lib/generators/katapult/basics/templates/config/initializers/better_errors.rb
katapult-0.4.1 lib/generators/katapult/basics/templates/config/initializers/better_errors.rb
katapult-0.4.0 lib/generators/katapult/basics/templates/config/initializers/better_errors.rb
katapult-0.3.0 lib/generators/katapult/basics/templates/config/initializers/better_errors.rb