From 88ffc089e7bd56b1fb90e16326a0678ab666a4bc Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 14 Feb 2024 21:27:04 +0000 Subject: [PATCH] Better error handling for file size specs --- cpdfcommand.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 5b2deff..57daf97 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1137,7 +1137,10 @@ let displaydoctitle b = _ -> failwith "DisplayDocTitle: must use true or false" let read_file_size s = - let read_int s = int_of_string (implode (rev s)) in + let read_int s' = + try int_of_string (implode (rev s')) with + _ -> error (Printf.sprintf "Could not read file size specification %s" s) + in match rev (explode (String.uppercase_ascii s)) with | 'B'::'I'::'G'::s -> 1024 * 1024 * 1024 * read_int s | 'B'::'G'::s -> 1000 * 1000 * 1000 * read_int s