Sha256: edc6368230c37a21b56bc6fe8b08d0c59a4a2f741f8c3ed0034f0c0c25511153

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

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
      if err
        message << <<~MSG
          Encountered error: \"#{err}\"
        MSG
        backtrace = err.backtrace.join("\n")
      else
        backtrace = nil
      end
      message << <<~MSG
        when prerendering #{component_name} with props: #{props}
        js_code was:
        #{js_code}
      MSG

      if console_messages
        message << <<~MSG
          console messages:
          #{console_messages}
        MSG
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
react_on_rails-8.0.2 lib/react_on_rails/prerender_error.rb