error handling

This commit is contained in:
John Whitington 2021-10-06 18:58:24 +01:00
parent 3526acb3ac
commit 140c48933b
1 changed files with 5 additions and 1 deletions

View File

@ -418,4 +418,8 @@ let to_output o parse_content no_stream_data decompress_streams pdf =
(* FIXME Proper streaming to output / from input, rather than making a big string first. *) (* FIXME Proper streaming to output / from input, rather than making a big string first. *)
let of_input i = let of_input i =
let content = Pdfio.string_of_bytes (Pdfio.bytes_of_input i 0 (i.Pdfio.in_channel_length)) in let content = Pdfio.string_of_bytes (Pdfio.bytes_of_input i 0 (i.Pdfio.in_channel_length)) in
pdf_of_json (J.from_string content) let json =
try J.from_string content with
e -> error (Printexc.to_string e)
in
pdf_of_json json