From 69bda9fb36ef58c3dab3478ea7d05c1e7c8b1503 Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Sun, 14 Sep 2025 17:21:36 -0500 Subject: [PATCH] fix: resolve Python FileNotFoundError and improve error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add proper error handling around temp_typst.unlink() in generate.py to prevent crashes when temp file doesn't exist - Modify ServerSorobanSVG component to throw errors instead of showing fallback when backend fails 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- apps/web/src/components/ServerSorobanSVG.tsx | 3 +-- packages/core/src/generate.py | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/ServerSorobanSVG.tsx b/apps/web/src/components/ServerSorobanSVG.tsx index dad5cccf..25d16015 100644 --- a/apps/web/src/components/ServerSorobanSVG.tsx +++ b/apps/web/src/components/ServerSorobanSVG.tsx @@ -63,8 +63,7 @@ export function ServerSorobanSVG({ } catch (err) { console.error(`Failed to generate SVG for ${number}:`, err) setError('Unable to generate SVG') - // Use fallback placeholder - setSvgContent(generateFallbackSVG(number, width, height)) + throw new Error(`Failed to generate SVG for number ${number}: ${err instanceof Error ? err.message : 'Unknown error'}`) } finally { setIsLoading(false) } diff --git a/packages/core/src/generate.py b/packages/core/src/generate.py index 765afd30..97a6fc25 100755 --- a/packages/core/src/generate.py +++ b/packages/core/src/generate.py @@ -415,7 +415,11 @@ def main(): print(f"Generated: {output_path}") # Clean up temp file - temp_typst.unlink() + try: + temp_typst.unlink() + except FileNotFoundError: + # Temp file may have already been cleaned up or not created + pass # Add duplex printing hints and linearize if requested if args.linearize: