Skip to content

Commit 57636ca

Browse files
committed
Do not crash on -I directory that cannot be opened
Signed-off-by: Paul-Elliot <[email protected]>
1 parent 823cc70 commit 57636ca

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/odoc/resolver.ml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ end = struct
4646
let unit_cache = Hashtbl.create 42 in
4747
List.iter
4848
(fun directory ->
49-
let files = Sys.readdir (Fs.Directory.to_string directory) in
50-
Array.iter
51-
(fun file ->
52-
let file = Fpath.v file in
53-
if Fpath.has_ext "odoc" file then
54-
Hashtbl.add unit_cache
55-
(Astring.String.Ascii.capitalize
56-
(file |> Fpath.rem_ext |> Fpath.basename))
57-
(Fs.File.append directory file))
58-
files)
49+
try
50+
let files = Sys.readdir (Fs.Directory.to_string directory) in
51+
Array.iter
52+
(fun file ->
53+
let file = Fpath.v file in
54+
if Fpath.has_ext "odoc" file then
55+
Hashtbl.add unit_cache
56+
(Astring.String.Ascii.capitalize
57+
(file |> Fpath.rem_ext |> Fpath.basename))
58+
(Fs.File.append directory file))
59+
files
60+
with Sys_error _ ->
61+
(* TODO: Raise a warning if a directory given as -I cannot be opened *)
62+
())
5963
directories;
6064
unit_cache
6165

0 commit comments

Comments
 (0)