Skip to content

Commit ba8cd9c

Browse files
authored
Merge pull request #6622 from roed314/g2c_err
Improve error handling in g2c
2 parents 4595a86 + 4a530b1 commit ba8cd9c

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

lmfdb/genus2_curves/main.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -539,26 +539,30 @@ def genus2_jump(info):
539539
errmsg = f"unable to find equation {eqn_str} (interpreted from %s) in the genus 2 curve database"
540540
elif jump.count('=') == 1:
541541
lhs_str, rhs_str = jump.split('=')
542+
errmsg = "Unable to parse input %s into a polynomial"
542543
try:
543544
rhs_poly = coeff_to_poly_multi(rhs_str)
544-
main_poly_str = lhs_str + "+" + str(-rhs_poly)
545-
main_poly = coeff_to_poly_multi(main_poly_str)
546545
except Exception:
547-
errmsg = "Unable to parse input %s into a polynomial"
548-
flash_error(errmsg, main_poly_str)
549-
return redirect(url_for(".index"))
550-
try:
551-
f,h = unpack_hyperelliptic_polys(main_poly)
552-
except ValueError as e:
553-
flash_error(str(e), main_poly)
554-
return redirect(url_for(".index"))
555-
new_input = str(f) + "," + str(h)
556-
label, eqn_str = genus2_lookup_equation(new_input)
557-
if label:
558-
return redirect(url_for_curve_label(label), 301)
559-
elif label is None:
560-
# the input was parsed
561-
errmsg = f"unable to find equation {eqn_str} (interpreted from %s) in the genus 2 curve database"
546+
jump = rhs_str
547+
else:
548+
try:
549+
main_poly_str = lhs_str + "+" + str(-rhs_poly)
550+
main_poly = coeff_to_poly_multi(main_poly_str)
551+
except Exception:
552+
jump = main_poly_str
553+
else:
554+
try:
555+
f,h = unpack_hyperelliptic_polys(main_poly)
556+
except ValueError as e:
557+
errmsg, jump = str(e), main_poly
558+
else:
559+
new_input = str(f) + "," + str(h)
560+
label, eqn_str = genus2_lookup_equation(new_input)
561+
if label:
562+
return redirect(url_for_curve_label(label), 301)
563+
elif label is None:
564+
# the input was parsed
565+
errmsg = f"unable to find equation {eqn_str} (interpreted from %s) in the genus 2 curve database"
562566
else:
563567
errmsg = "%s is not valid input. Expected a label, e.g., 169.a.169.1"
564568
errmsg += ", or a univariate polynomial, e.g., x^5 + 1"

0 commit comments

Comments
 (0)