Sha256: 79bc6bec762d6dc7c2dcd50238a8024f5b10001f1500dd2290176e85bcf57dce

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

# rubocop:disable: Layout/IndentHeredoc
module ReactOnRails
  class PrerenderError < RuntimeError
    # err might be nil if JS caught the error
    def initialize(component_name: nil, err: nil, props: nil,
                   js_code: nil, console_messages: nil)
      message = "ERROR in SERVER PRERENDERING\n".dup # rubocop:disable Performance/UnfreezeString
      if err
        # rubocop:disable Layout/IndentHeredoc
        message << <<-MSG
Encountered error: \"#{err}\"
        MSG
        # rubocop:enable Layout/IndentHeredoc
        backtrace = err.backtrace.join("\n")
      else
        backtrace = nil
      end
      # rubocop:disable Layout/IndentHeredoc
      message << <<-MSG
when prerendering #{component_name} with props: #{props}
js_code was:
#{js_code}
      MSG
      # rubocop:enable Layout/IndentHeredoc

      if console_messages
        # rubocop:disable Layout/IndentHeredoc
        message << <<-MSG
console messages:
#{console_messages}
        MSG
        # rubocop:enable Layout/IndentHeredoc
      end

      super([message, backtrace].compact.join("\n"))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
react_on_rails-10.0.2 lib/react_on_rails/prerender_error.rb
react_on_rails-10.0.1 lib/react_on_rails/prerender_error.rb
react_on_rails-10.0.0 lib/react_on_rails/prerender_error.rb