From 53b2cce48f9e5ad61ca6de1e3fc5b7a11a1523cc Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Tue, 16 Jul 2019 19:11:18 +0200 Subject: [PATCH] read_text dies if file does not exist; return undef instead --- modules/util/Util/JSON.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/util/Util/JSON.pm b/modules/util/Util/JSON.pm index c81bd7b..e543c65 100755 --- a/modules/util/Util/JSON.pm +++ b/modules/util/Util/JSON.pm @@ -24,7 +24,16 @@ sub read_json_file =end comment =cut - my $json_text= read_text($fnm); + my $json_text; + eval + { + $json_text= read_text($fnm); + }; + + if ($@) + { + return undef; + } from_json($json_text); } -- GitLab