From ee8bf048a0047ad2256cd4cca52e49c01ea088f5 Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Tue, 25 Aug 2020 08:57:35 +0200 Subject: [PATCH] [Server] fail more gracefully with invalid JSON files --- src/plugins/server/server_batch.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/server/server_batch.ml b/src/plugins/server/server_batch.ml index 2df2d4d2567..4fc37a40aa6 100644 --- a/src/plugins/server/server_batch.ml +++ b/src/plugins/server/server_batch.ml @@ -102,7 +102,13 @@ let execute () = List.iter begin fun file -> Senv.feedback "Script %S" file ; - let response = execute_batch (Js.from_file file) in + let response = + try + execute_batch (Js.from_file file) + with Yojson.Json_error msg -> + Senv.error "[batch] error in JSON file:@\n%s@." msg; + `Null + in let output = Filename.remove_extension file ^ ".out.json" in let output = match BatchOutputDir.get () with | "" -> output -- GitLab