From 140c48933bb35932f3b83ffa1abbf9af2c9ee932 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 6 Oct 2021 18:58:24 +0100 Subject: [PATCH] error handling --- cpdfjson.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpdfjson.ml b/cpdfjson.ml index 6560afa..d7e57bc 100644 --- a/cpdfjson.ml +++ b/cpdfjson.ml @@ -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. *) let of_input i = 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