Overview
Splat’s error analysis system transforms cryptic stack traces into actionable insights. It combines regex-based parsing, context gathering, and LLM-powered analysis to identify not just what went wrong, but why and how to fix it.Error Capture Process
Subprocess Execution
Splat runs your command as a subprocess to intercept all output:relational.py
check=True causes subprocess to raise CalledProcessError on non-zero exit codes, allowing Splat to catch failures.Error Components
Splat captures three distinct pieces of information:Stack Trace Parsing
Regex Pattern Matching
Theparse_error_stack function uses a sophisticated regex to extract file paths:
utils/utils.py
Pattern Breakdown
The regexr'(?:File "([^"]+)"|\b(\S+\.py)\b)' handles two cases:
Example Trace Analysis
Let’s walk through a real error:Example Error
Extraction Results
LLM-Powered Analysis
Structured Prompting
Splat uses a multi-message prompt system to guide the LLM:process/process.py
Multiple system messages provide instructions, format specification, and constraints separately for better LLM adherence.
Response Format
The LLM returns structured analysis:Why JSON Output?
Programmatic Parsing
Programmatic Parsing
JSON allows Splat to extract specific fields (file, line, fix) without brittle text parsing.
Consistent Structure
Consistent Structure
Forces the LLM to provide all required information in a predictable format.
UI Integration
UI Integration
Enables rich terminal display with color-coded sections and interactive navigation.
Analysis Modes
Splat offers two analysis depths:- Basic Mode
- Relational Mode (-r)
Analyzes only files directly mentioned in the error trace.Pros: Fast, minimal context
Cons: May miss root cause in imported modules
Terminal Output
Interactive Display
Parsed results are rendered with rich formatting:terminalout/terminal.py
User Interaction
After displaying analysis, users can accept/reject the fix:Error Type Detection
The LLM categorizes errors into Python’s exception hierarchy:- SyntaxError - Malformed code that can’t parse
- NameError - Undefined variable/function reference
- TypeError - Operation on incompatible types
- AttributeError - Invalid attribute access
- ImportError - Failed module import
- IndexError - Sequence index out of range
The LLM provides the specific error type in the
what.error_type field, enabling type-specific handling in future versions.Best Practices
Use -r for Complex Errors
When errors involve multiple files, relational mode provides crucial import context.
Check Line Numbers
Verify the LLM identified the correct line - occasionally it may pinpoint a symptom rather than the root cause.
Review Suggested Fixes
Always understand the proposed solution before applying - the LLM may miss edge cases.
Provide Clean Commands
Ensure your entrypoint command runs correctly without Splat first to isolate issues.
Next Steps
Dependency Graphs
Learn how Splat maps file relationships for relational mode
How It Works
Understand the complete Splat architecture