Skip to content

Commit 271e094

Browse files
justin808claude
andcommitted
Add RBS type signatures for error classes (#2004)
## Summary Adds RBS type signatures for all error-related classes to complete type coverage for the gem. ## Changes Added RBS signatures for: - `ReactOnRails::Error` - Base error class - `ReactOnRails::JsonParseError` - JSON parsing error with context - `ReactOnRails::PrerenderError` - Server rendering error with detailed info - `ReactOnRails::SmartError` - Enhanced error with actionable suggestions ## Files Added - `sig/react_on_rails/error.rbs` - `sig/react_on_rails/json_parse_error.rbs` - `sig/react_on_rails/prerender_error.rbs` - `sig/react_on_rails/smart_error.rbs` ## Testing - RuboCop passes - RBS files follow existing patterns in the codebase - Type signatures match the actual implementations ## Related Fixes #1954 (follow-up to PR #1945) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2004) <!-- Reviewable:end --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent e162b9b commit 271e094

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

sig/react_on_rails/error.rbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ReactOnRails
2+
class Error < StandardError
3+
end
4+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module ReactOnRails
2+
class JsonParseError < ::ReactOnRails::Error
3+
attr_reader json: String
4+
5+
def initialize: (parse_error: StandardError, json: String) -> void
6+
def to_honeybadger_context: () -> Hash[Symbol, untyped]
7+
def raven_context: () -> Hash[Symbol, untyped]
8+
def to_error_context: () -> Hash[Symbol, untyped]
9+
end
10+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module ReactOnRails
2+
class PrerenderError < ::ReactOnRails::Error
3+
MAX_ERROR_SNIPPET_TO_LOG: Integer
4+
5+
attr_reader component_name: String?
6+
attr_reader err: StandardError?
7+
attr_reader props: String?
8+
attr_reader js_code: String?
9+
attr_reader console_messages: String?
10+
11+
def initialize: (?component_name: String?, ?err: StandardError?, ?props: String?, ?js_code: String?, ?console_messages: String?) -> void
12+
def to_honeybadger_context: () -> Hash[Symbol, untyped]
13+
def raven_context: () -> Hash[Symbol, untyped]
14+
def to_error_context: () -> Hash[Symbol, untyped]
15+
16+
private
17+
18+
def calc_message: (String? component_name, String? console_messages, StandardError? err, String? js_code, String? props) -> [String?, String]
19+
def build_troubleshooting_suggestions: (String? component_name, StandardError? err, String? console_messages) -> String
20+
end
21+
end

sig/react_on_rails/smart_error.rbs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module ReactOnRails
2+
class SmartError < Error
3+
attr_reader error_type: Symbol
4+
attr_reader component_name: String?
5+
attr_reader props: String?
6+
attr_reader js_code: String?
7+
attr_reader additional_context: Hash[Symbol, untyped]
8+
9+
def initialize: (error_type: Symbol, ?component_name: String?, ?props: String?, ?js_code: String?, **untyped additional_context) -> void
10+
def solution: () -> String
11+
12+
private
13+
14+
def build_error_message: () -> String
15+
def error_type_title: () -> String
16+
def error_description: () -> String
17+
def component_not_registered_solution: () -> String
18+
def missing_auto_loaded_bundle_solution: () -> String
19+
def hydration_mismatch_solution: () -> String
20+
def server_rendering_error_solution: () -> String
21+
def redux_store_not_found_solution: () -> String
22+
def configuration_error_solution: () -> String
23+
def default_solution: () -> String
24+
def additional_info: () -> String
25+
def troubleshooting_section: () -> String
26+
def find_similar_components: (String name) -> Array[String]
27+
end
28+
end

0 commit comments

Comments
 (0)