Tutorial 5: Error Handling and Debugging
Let's intentionally create errors to see how TatML helps you fix them.
Step 1: Create a Pattern with Errors
Create buggy_pattern.tatml:
pattern "Buggy Pattern" {
ring1: R(5, p, 5)
chain1: C(6, join(ring1.picot3), 6) // Error: ring1 only has 1 picot
ring2: R(2, join(ring2.picot1), 2) // Error: can't join to self
isolated: R(8, p, 8) // Warning: isolated element
}
Step 2: Run Validation
python3 tatml_validator.py buggy_pattern.tatml
You'll see helpful error messages:
❌ 2 Error(s):
Element 'ring1' only has 1 picots, cannot access picot3
Suggestion: Valid range: picot1 to picot1
Ring 'ring2' cannot join to itself
Suggestion: Rings cannot join to their own picots during construction
⚠️ 1 Warning(s):
Element 'isolated' appears to be isolated
Suggestion: Consider adding joins to connect this element to the pattern
Step 3: Fix the Errors
pattern "Fixed Pattern" {
ring1: R(5, p, 5, p, 5) // Added second picot
chain1: C(6, join(ring1.picot2), 6) // Fixed: now references valid picot
ring2: R(4, join(chain1.picot1), 4) // Fixed: joins to chain instead of self
connector: C(6, join(ring2.picot1), 6, join(ring1.picot1), 6) // Connected isolated element
}