Skip to content

Commit 8e1875d

Browse files
justin808claude
andcommitted
Add help messages to additional error classes
Display support and troubleshooting links in more error scenarios: - PrerenderError: Shows help when server rendering fails - JsonParseError: Shows help when JSON parsing fails - Server rendering pool errors: Shows help for bundle compilation and evaluation errors This ensures users see helpful support information regardless of the error type they encounter. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2c67f41 commit 8e1875d

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

lib/react_on_rails/json_parse_error.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class JsonParseError < ::ReactOnRails::Error
77
def initialize(parse_error:, json:)
88
@json = json
99
@original_error = parse_error
10-
super(parse_error.message)
10+
message = "#{parse_error.message}\n\n#{Utils.extract_troubleshooting_section}"
11+
super(message)
1112
end
1213

1314
def to_honeybadger_context

lib/react_on_rails/prerender_error.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def calc_message(component_name, console_messages, err, js_code, props)
8383
MSG
8484

8585
end
86+
87+
# Add help and support information
88+
message << "\n#{Utils.extract_troubleshooting_section}\n"
89+
8690
[backtrace, message]
8791
end
8892
end

lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil)
7777
if err.message.include?("ReferenceError: self is not defined")
7878
msg << "\nError indicates that you may have code-splitting incorrectly enabled.\n"
7979
end
80+
msg << "\n#{Utils.extract_troubleshooting_section}\n"
8081
raise ReactOnRails::Error, msg, err.backtrace
8182
end
8283

@@ -122,7 +123,7 @@ def read_bundle_js_code
122123
rescue StandardError => e
123124
msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be " \
124125
"read. You may set the server_bundle_js_file in your configuration to be \"\" to " \
125-
"avoid this warning.\nError is: #{e}"
126+
"avoid this warning.\nError is: #{e}\n\n#{Utils.extract_troubleshooting_section}"
126127
raise ReactOnRails::Error, msg
127128
end
128129

@@ -149,11 +150,12 @@ def create_js_context
149150
msg = "ERROR when compiling base_js_code! " \
150151
"See file #{file_name} to " \
151152
"correlate line numbers of error. Error is\n\n#{e.message}" \
152-
"\n\n#{e.backtrace.join("\n")}"
153+
"\n\n#{e.backtrace.join("\n")}" \
154+
"\n\n#{Utils.extract_troubleshooting_section}"
153155
Rails.logger.error(msg)
154156
trace_js_code_used("Error when compiling JavaScript code for the context.", base_js_code,
155157
file_name, force: true)
156-
raise e
158+
raise ReactOnRails::Error, msg
157159
end
158160
end
159161

@@ -227,7 +229,7 @@ def file_url_to_string(url)
227229
encoding_type = match[:encoding]
228230
response.body.force_encoding(encoding_type)
229231
rescue StandardError => e
230-
msg = "file_url_to_string #{url} failed\nError is: #{e}"
232+
msg = "file_url_to_string #{url} failed\nError is: #{e}\n\n#{Utils.extract_troubleshooting_section}"
231233
raise ReactOnRails::Error, msg
232234
end
233235

0 commit comments

Comments
 (0)