Browse Source

Added more exception handling in c_compiler_cmd

If there is any error, even writing the simple.cpp file, catch it and just return a "I don't know" diagnosis
pull/63/head
Kevin Bogusch 5 months ago
parent
commit
bc8229947d
  1. 12
      week4/day4.ipynb

12
week4/day4.ipynb

@ -455,7 +455,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 111,
"id": "e42286bc-085c-45dc-b101-234308e58269",
"metadata": {},
"outputs": [],
@ -482,14 +482,12 @@
" return \"\"\n",
"\n",
"def c_compiler_cmd(filename_base):\n",
"\n",
" with open(\"simple.cpp\", \"w\") as f:\n",
" f.write(simple_cpp)\n",
"\n",
" \n",
" my_platform = platform.system()\n",
" my_compiler = []\n",
"\n",
" try:\n",
" with open(\"simple.cpp\", \"w\") as f:\n",
" f.write(simple_cpp)\n",
" \n",
" if my_platform == \"Windows\":\n",
" if os.path.isfile(VISUAL_STUDIO_2022_TOOLS):\n",
@ -550,6 +548,8 @@
" \n",
" if not my_compiler:\n",
" my_compiler=[my_platform, \"Unavailable\", []]\n",
" except:\n",
" my_compiler=[my_platform, \"Unavailable\", []]\n",
" \n",
" if my_compiler:\n",
" return my_compiler\n",

Loading…
Cancel
Save