瀏覽代碼

feat: python error handling

Timothy J. Baek 11 月之前
父節點
當前提交
1140036f20
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/lib/components/chat/Messages/CodeBlock.svelte

+ 5 - 1
src/lib/components/chat/Messages/CodeBlock.svelte

@@ -47,7 +47,11 @@ original_stdout = sys.stdout
 # Replace the standard output with the StringIO object
 sys.stdout = output_capture
 
-${text}
+try:
+	${text}
+except Exception as e:
+    # Capture any errors and write them to the output capture
+    print(f"Error: {e}", file=output_capture)
 
 # Restore the original standard output
 sys.stdout = original_stdout