feat: Introduce StacError and StacErrorWidget for enhanced error handling#364
feat: Introduce StacError and StacErrorWidget for enhanced error handling#364divyanshub024 merged 4 commits intodevfrom
Conversation
…ling - Add StacError class to encapsulate details about parsing and runtime errors, including type, original JSON, and stack trace. - Implement StacErrorWidget to display structured error information, providing context and troubleshooting tips for developers. - Update StacService to utilize StacError for error reporting and display custom error widgets when parsing fails. - Enhance error handling in JSON parsing and action execution with detailed logging and optional error widgets.
WalkthroughAdds configurable error handling and UI: introduces StacError model and StacErrorWidget, a StacErrorWidgetBuilder typedef, and new initialization flags (showErrorWidgets, logStackTraces, errorWidgetBuilder) propagated from Stac to StacService; centralizes error logging/building. Removes StacOutlineInputBorder implementation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor App
participant Stac
participant StacService
participant Logger as _logError
participant Builder as _buildErrorWidget
App->>Stac: initialize(showErrorWidgets, logStackTraces, errorWidgetBuilder)
Stac->>StacService: initialize(..., showErrorWidgets, logStackTraces, errorWidgetBuilder)
rect rgba(200,230,255,0.25)
note over StacService: parsing / action / loading flows
App->>StacService: fromJson / fromStacWidget / load(...)
alt success
StacService-->>App: widget/result
else error
StacService->>Logger: _logError(details[, stackTrace])
alt showErrorWidgets AND debug
StacService->>Builder: _buildErrorWidget(details)
Builder-->>StacService: StacErrorWidget (custom or default)
StacService-->>App: Error widget
else
StacService-->>App: null / fallback
end
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🔇 Additional comments (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/stac/lib/src/framework/stac_service.dart (1)
421-423: Minor: Avoid unnecessary toString() on already-String asset data.
Use snapshot.data! directly for jsonDecode.- final json = jsonDecode(snapshot.data.toString()); + final json = jsonDecode(snapshot.data!);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/stac/lib/src/framework/stac.dart(3 hunks)packages/stac/lib/src/framework/stac_error.dart(1 hunks)packages/stac/lib/src/framework/stac_service.dart(8 hunks)packages/stac/lib/src/framework/ui/stac_outline_input_border.dart(0 hunks)
💤 Files with no reviewable changes (1)
- packages/stac/lib/src/framework/ui/stac_outline_input_border.dart
🔇 Additional comments (6)
packages/stac/lib/src/framework/stac.dart (2)
6-6: Import for StacError looks good.
49-62: Initialize wiring (showErrorWidgets/logStackTraces/errorWidgetBuilder) — LGTM.Properly threads options down to StacService.initialize.
packages/stac/lib/src/framework/stac_service.dart (4)
5-5: Good call hiding Flutter’s ErrorWidgetBuilder.
Prevents typedef collision with the local one from stac.dart.
181-241: fromJson validations and debug-only error widget — LGTM.
Null/field checks, structured logging, and gated error UI are consistent.
453-475: Centralized logging helper — LGTM.
Compact message + optional stack trace gating is clean and consistent.
483-493: Custom/default error widget selection — LGTM.
Respects provided builder; otherwise falls back to StacErrorWidget. Debug-only governed upstream.
…dling - Rename error parameter to errorDetails in StacErrorWidget for clarity. - Update documentation to reflect changes in error handling, including removal of stack trace display in the UI. - Ensure consistent usage of errorDetails across StacErrorWidget and related components.
Description
Related Issues
Closes #
Type of Change
Summary by CodeRabbit
New Features
Refactor
Revert