Sha256: 9cfe32d116c25a3edbe83f0894f77d84aad92cbc23eb67468d931df7ee5f0f85

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

# rubocop:disable: Layout/IndentHeredoc
module ReactOnRails
  class PrerenderError < StandardError
    # 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
        # 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

6 entries across 6 versions & 1 rubygems

Version Path
react_on_rails-11.0.4 lib/react_on_rails/prerender_error.rb
react_on_rails-11.0.3 lib/react_on_rails/prerender_error.rb
react_on_rails-11.0.2 lib/react_on_rails/prerender_error.rb
react_on_rails-11.0.1 lib/react_on_rails/prerender_error.rb
react_on_rails-11.0.0 lib/react_on_rails/prerender_error.rb
react_on_rails-11.0.0.beta.1 lib/react_on_rails/prerender_error.rb