Better error reporting for bookmark files

This commit is contained in:
John Whitington 2016-04-08 20:13:22 +01:00
parent 6d745cbdc7
commit 5b72334a9e
1 changed files with 2 additions and 2 deletions

View File

@ -947,6 +947,7 @@ let rec fixup_characters prev = function
| h::t -> fixup_characters (h::prev) t | h::t -> fixup_characters (h::prev) t
let parse_bookmark_file verify pdf input = let parse_bookmark_file verify pdf input =
let currline = ref 0 in
try try
let lines = Pdfio.read_lines input in let lines = Pdfio.read_lines input in
(*i Printf.printf "Read %i lines\n" (length lines); (*i Printf.printf "Read %i lines\n" (length lines);
@ -974,7 +975,6 @@ let parse_bookmark_file verify pdf input =
Pdfmarks.isopen = false} Pdfmarks.isopen = false}
| [] -> () (* ignore blank lines *) | [] -> () (* ignore blank lines *)
| _ -> | _ ->
(*i flprint (Pdfgenlex.string_of_tokens n); i*)
error ("Bad bookmark file, line " ^ (string_of_int !currline))) error ("Bad bookmark file, line " ^ (string_of_int !currline)))
lines; lines;
let bookmarks = rev !bookmarks in let bookmarks = rev !bookmarks in
@ -987,7 +987,7 @@ let parse_bookmark_file verify pdf input =
else else
bookmarks bookmarks
with with
_ -> (*i Printf.printf "%s\n" (Printexc.to_string e); i*) error "Bad bookmark file (syntax)" _ -> error (Printf.sprintf "Bad bookmark file (syntax) at line %i" !currline)
let add_bookmarks verify input pdf = let add_bookmarks verify input pdf =