[sledge] Make reading config file more robust

Summary: There are exceptions everywhere in Yojson.

Reviewed By: jvillard

Differential Revision: D27279241

fbshipit-source-id: ce77fd241
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent 4689a2881d
commit 8d1743bf27

@ -28,10 +28,15 @@ let contents =
config_file config_file_env_var () ;
`Assoc []
let find key = Yojson.Basic.Util.(to_string_option (member key contents))
module YBU = Yojson.Basic.Util
let find key =
try YBU.to_string_option (YBU.member key contents)
with YBU.Type_error _ -> None
let find_list key =
Yojson.Basic.Util.(filter_string (to_list (member key contents)))
try YBU.filter_string (YBU.to_list (YBU.member key contents))
with YBU.Type_error _ -> []
let find_exn key =
match find key with

Loading…
Cancel
Save