Back to all reviewers

Prevent regression crashes

facebook/react-native
Based on 3 comments
Java

When implementing error handling or bug fixes, avoid introducing new crash conditions that would break previously working code. Focus on defensive programming that handles edge cases without creating new failure points.

Error Handling Java

Reviewer Prompt

When implementing error handling or bug fixes, avoid introducing new crash conditions that would break previously working code. Focus on defensive programming that handles edge cases without creating new failure points.

Key principles:

  1. Backward compatibility first: Don’t add new validation that crashes on previously accepted inputs
  2. Complete error handling: Ensure all code paths have proper error responses (like calling onResponseReceived for all URI handlers)
  3. Proper state management: Reset and initialize state variables in lifecycle methods to prevent recycling issues

Example from accessibility handling:

// DON'T: Add new crash conditions
if (!action.hasKey("name") || !action.hasKey("label")) {
  // This crashes apps that worked before without labels

// DO: Handle missing data gracefully  
if (!action.hasKey("name")) {
  continue; // Skip invalid actions without crashing
}
if (action.hasKey("label")) {
  // Use label when available, but don't require it
}

Before adding new error conditions, consider whether the change maintains backward compatibility while still providing proper error handling for new scenarios.

3
Comments Analyzed
Java
Primary Language
Error Handling
Category

Source Discussions