Skip to content

Commit e5b89d3

Browse files
justin808claude
andcommitted
Add JSON parse error handling in apply_minimum_versions
Improves error handling by catching and logging JSON parse errors when reading package.json during minimum version configuration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7ea065d commit e5b89d3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

react_on_rails/rakelib/shakapacker_examples.rake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
1717
include ReactOnRails::TaskHelpers
1818

1919
# Updates package.json to use minimum supported versions for compatibility testing
20-
def apply_minimum_versions(dir)
20+
def apply_minimum_versions(dir) # rubocop:disable Metrics/CyclomaticComplexity
2121
package_json_path = File.join(dir, "package.json")
2222
return unless File.exist?(package_json_path)
2323

24-
package_json = JSON.parse(File.read(package_json_path))
24+
begin
25+
package_json = JSON.parse(File.read(package_json_path))
26+
rescue JSON::ParserError => e
27+
puts " ERROR: Failed to parse package.json in #{dir}: #{e.message}"
28+
raise
29+
end
2530

2631
# Update React versions to minimum supported
2732
if package_json["dependencies"]

0 commit comments

Comments
 (0)