Skip to content

Commit

Permalink
Don't log full props or JS code
Browse files Browse the repository at this point in the history
Long props result in very long error messages
  • Loading branch information
justin808 committed Jul 22, 2018
1 parent ea9d87a commit 989f01b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/react_on_rails/prerender_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# rubocop:disable: Layout/IndentHeredoc
module ReactOnRails
class PrerenderError < ::ReactOnRails::Error
MAX_ERROR_SNIPPET_TO_LOG = 1000
# TODO: Consider remove providing original `err` as already have access to `self.cause`
# http://blog.honeybadger.io/nested-errors-in-ruby-with-exception-cause/
attr_reader :component_name, :err, :props, :js_code, :console_messages
Expand Down Expand Up @@ -58,9 +59,9 @@ def calc_message(component_name, console_messages, err, js_code, props)
end
# rubocop:disable Layout/IndentHeredoc
message << <<-MSG
when prerendering #{component_name} with props: #{props}
when prerendering #{component_name} with props (truncated): #{props.to_s[0, MAX_ERROR_SNIPPET_TO_LOG]}
js_code was:
#{js_code}
#{js_code[0, MAX_ERROR_SNIPPET_TO_LOG]}
MSG
# rubocop:enable Layout/IndentHeredoc

Expand Down

0 comments on commit 989f01b

Please sign in to comment.