Skip to content

Commit 0828b12

Browse files
committed
catch ValueError that is raised on axis editor data that cannot be cast to float
1 parent a5434e5 commit 0828b12

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/slice/__main__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,21 @@ def btn_clicked_slice(self):
551551
self.statusbar.update()
552552
# must keep this return statement to abort execution!
553553
return
554-
elif not self.fvar_table_model.instance_data_validates_missing_data():
554+
555+
# validate axis editor instance values
556+
# returns True/False response for test of
557+
# at least one instance value
558+
# raises ValueError on attempt to cast to float
559+
# if the entry is a non-numeric value
560+
try:
561+
instance_values_are_present = (
562+
self.fvar_table_model.instance_data_validates_missing_data()
563+
)
564+
except ValueError as e:
565+
SliceErrorDialog(f"{e}")
566+
return
567+
568+
if not instance_values_are_present:
555569
SliceErrorDialog(
556570
"You requested the same design space that is supported in the "
557571
"font path that you are processing. Please define at least one "

src/slice/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def get_instance_data(self):
288288
except ValueError:
289289
raise ValueError(
290290
f"'{axis_value}' is not a valid {axistag} axis value. "
291-
f"Please enter a valid value and try again."
291+
f"Please enter a single numeric value and try again."
292292
)
293293

294294
return instance_data
@@ -298,7 +298,10 @@ def instance_data_validates_missing_data(self):
298298
# axis tag with a defined instance, and False if all
299299
# axis tags have blank entry fields = the original variable
300300
# font that the user entered
301-
return len(self.get_instance_data()) != 0
301+
try:
302+
return len(self.get_instance_data()) != 0
303+
except ValueError as e:
304+
raise e
302305

303306
def get_default_axis_value(self, axistag):
304307
if axistag in self.fvar_axes:

0 commit comments

Comments
 (0)