Skip to content

Commit 01d33f9

Browse files
committed
More graceful handling of non-regular regex
1 parent 93966e6 commit 01d33f9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

jsonsubschema/_utils.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ def regex_isSubset(s1, s2):
194194
# see https://github.com/qntm/greenery/blob/master/greenery/lego.py
195195
# ... raise Exception("Please choose an 'otherchar'")
196196
return s1.equivalent(s2) or (s1 & s2.everythingbut()).empty()
197+
except Exception as e:
198+
exit_with_msg("regex failure from greenry", e)
197199
elif s1:
198200
return True
199201
elif s2:
@@ -343,9 +345,9 @@ def load_json_file(path, msg=None):
343345
try:
344346
return json.load(fh)
345347
except Exception as e:
346-
if msg:
347-
print(msg, e)
348-
sys.exit(1)
349-
else:
350-
print(e)
351-
sys.exit(1)
348+
exit_with_msg(msg, e)
349+
350+
351+
def exit_with_msg(msg, e=None):
352+
print("Message:", msg, ";", "Exception:", e)
353+
sys.exit(1)

0 commit comments

Comments
 (0)