From 8164f685214c14156099bc306a3d1879fc942caa Mon Sep 17 00:00:00 2001 From: ivg Date: Thu, 18 Aug 2022 09:57:02 -0400 Subject: [PATCH] adds minimal error-handling Now instead of ignoring errors and spoiling stderr, we capture the output and failwith the captured message. Signed-off-by: ivg --- otherlibs/site/src/plugins/linker/toplevel/linker.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/otherlibs/site/src/plugins/linker/toplevel/linker.ml b/otherlibs/site/src/plugins/linker/toplevel/linker.ml index 563590db4366..3001b70181e8 100644 --- a/otherlibs/site/src/plugins/linker/toplevel/linker.ml +++ b/otherlibs/site/src/plugins/linker/toplevel/linker.ml @@ -1 +1,10 @@ -let load = Topdirs.dir_load Format.err_formatter +let load filename = + let buf = Buffer.create 16 in + let ppf = Format.formatter_of_buffer buf in + match Toploop.load_file ppf filename with + | true -> () + | false -> + Format.pp_print_flush ppf (); + failwith + @@ Format.asprintf "Failed to load file `%s': %s" filename + (Buffer.contents buf)