[svn-genapp] r1711 - tutorial2/bin

svn@...
 

Author: ehb
Date: Sun Sep 22 11:45:27 2019
New Revision: 1711

Log:
Catch valueerror

Modified:
tutorial2/bin/repeater.py

Modified: tutorial2/bin/repeater.py
==============================================================================
--- tutorial2/bin/repeater.py Sun Sep 22 11:04:07 2019 (r1710)
+++ tutorial2/bin/repeater.py Sun Sep 22 11:45:27 2019 (r1711)
@@ -11,8 +11,14 @@
if isinstance( json_variables, dict ) and \
'm' in json_variables and \
'c' in json_variables :
- mass = float(json_variables['m'])
- speed_of_light = float(json_variables['c'])
+ try:
+ mass = float(json_variables['m'])
+ except ValueError:
+ output['notice'] = "Expected JSON input variables 'm' and/or 'c' not found or incorrect type"
+ try:
+ speed_of_light = float(json_variables['c'])
+ except ValueError:
+ output['notice'] = "Expected JSON input variables 'm' and/or 'c' not found or incorrect type"

import mass_energy

Join genapp-commits@groups.io to automatically receive all group messages.