From 64b934f390a6a1db026e5d82e5c31b0412ce0853 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Fri, 13 Aug 2021 15:45:59 -0400 Subject: [PATCH] use Arg.bad instead of Failure exception when positional atomic number arguments --- elements.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/elements.ml b/elements.ml index 846b0f0..b5a778b 100644 --- a/elements.ml +++ b/elements.ml @@ -32,7 +32,10 @@ module Opts = struct let add_def s = match !ltype with | NAME -> add_name s | SYMB -> add_symb s - | NUMB -> add_numb (int_of_string s) + | NUMB -> add_numb (match int_of_string_opt s with + | None -> raise (Bad (Printf.sprintf "expected integer, got '%s'" s)) + | Some x -> x + ) let msg = "Periodic table search\n\ elements -gendb file [-dbfile outfile]\n\