Draft
Conversation
…orting - Add error-stack dependency to txtx-addon-kit and evm addon - Create core error types (TxtxError) with structured attachments - Implement ErrorAttachments trait for fluent error enhancement - Add compatibility layer for migrating from Diagnostic - Create EVM-specific error types demonstrating domain errors - Add comprehensive tests (18 passing) and demonstrations - Document implementation strategy and migration path This spike demonstrates how error-stack can provide: - Rich context preservation through error propagation - Type-safe error boundaries - Actionable error messages with documentation - Better debugging with automatic backtraces - Incremental migration from existing error handling
- Add CliError enum with common CLI error scenarios - Create rich attachments (ManifestInfo, RunbookContext, OutputInfo, etc.) - Implement enhanced error display with recovery suggestions - Add migration examples showing before/after patterns - Create working demo showing improved error messages Common errors now provide: - Clear context about what failed - Available alternatives (e.g., valid runbooks) - Actionable recovery steps - Links to documentation - Graceful fallbacks for output failures This migration demonstrates how error-stack dramatically improves the user experience by transforming cryptic errors into helpful guidance.
Collaborator
|
This is suuuuuuuuper cool. It would be a daunting task indeed to update the whole repo, but it would be incredible to have this in place. The main thing that's daunting is that the "gradual migration" isn't really possible. All of the addon functions implement a trait, which currently returns our |
92ccc36 to
2468c3b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Error-Stack Integration Spike for txtx
Overview
This document explores integrating the
error-stacklibrary into the txtx project to enhance error reporting with structured, context-rich error handling.Why error-stack?
The error-stack library addresses several weaknesses identified in our initial audit:
How to test
You can now see the new error-stack implementation in action by:
cargo test --package txtx-addon-kit errors::demo::tests::test_process_action_invalid_address -- --nocaptureThe key improvements you'll see:
The demo shows four different error scenarios:
Each demonstrates how error-stack provides significantly better error reporting than the current Diagnostic approach.
Integration Strategy
Phase 1: Define Core Error Types
Replace the current
Diagnosticwith error-stack based types:Phase 2: Create Domain-Specific Error Types
For each addon and major component:
Phase 3: Attachment Types for Rich Context
Define structured attachments to replace current diagnostic fields:
Phase 4: Error Creation Patterns
Replace
diagnosed_error!with error-stack patterns:Phase 5: Error Propagation
Update error propagation to preserve context:
Phase 6: Error Display
Implement rich error display using error-stack's formatting:
Migration Plan
Step 1: Add Dependency
Step 2: Create Compatibility Layer
During migration, create a compatibility layer:
Step 3: Gradual Migration
txtx-coreDiagnostictype once migration is completeBenefits
Considerations
Diagnosticwill need updatesExample: Before and After
Before (Current Diagnostic)
After (With error-stack)
Recommendation
The error-stack library would significantly improve txtx's error reporting by:
The migration effort is substantial but can be done incrementally, starting with new code and gradually updating existing error handling.