@@ -1302,15 +1302,20 @@ def preview_formcalc(self, get):
13021302 # TODO add references to valid variables and functions
13031303 # At some point, we might want to mark invalid variables as red
13041304 # or something, and this is where we would need to pass those in.
1305- from xmodule .capa_block import ProblemBlock
1306- numeric_result = ProblemBlock .preview_numeric_input (formula )
1307- # Map results into the correct format
1308- result ["preview" ] = numeric_result ["preview" ]
1309- if numeric_result ["error" ]:
1310- result ["error" ] = numeric_result ["error" ]
1311- # if formula is invalid return formula
1312- if not numeric_result ["is_valid" ]:
1313- result ["formula" ] = formula
1305+ try :
1306+ from xmodule .capa_block import ProblemBlock
1307+ numeric_result = ProblemBlock .preview_numeric_input (formula )
1308+ # Map results into the correct format
1309+ result ["preview" ] = numeric_result ["preview" ]
1310+ if numeric_result ["error" ]:
1311+ result ["error" ] = numeric_result ["error" ]
1312+ # if formula is invalid return formula
1313+ if not numeric_result ["is_valid" ]:
1314+ result ["formula" ] = formula
1315+ except Exception : # lint-amnesty, pylint: disable=broad-except
1316+ log .warning ("Error while previewing formula" , exc_info = True )
1317+ result ["error" ] = _ ("Error while rendering preview" )
1318+ return result
13141319
13151320 return result
13161321
0 commit comments