File tree Expand file tree Collapse file tree 4 files changed +44
-50
lines changed
Expand file tree Collapse file tree 4 files changed +44
-50
lines changed Original file line number Diff line number Diff line change @@ -173,39 +173,11 @@ let compute_target_digests_or_raise_error
173173 | Error errors ->
174174 let missing, errors =
175175 let process_target (target , error ) =
176- match error with
177- | Cached_digest.Digest_result.Error. No_such_file -> Left target
178- | Broken_symlink ->
179- let error = Pp. verbatim " Broken symbolic link" in
180- Right (target, error)
181- | Cyclic_symlink ->
182- let error = Pp. verbatim " Cyclic symbolic link" in
183- Right (target, error)
184- | Unexpected_kind file_kind ->
185- let error =
186- Pp. verbatim
187- (sprintf
188- " Unexpected file kind %S (%s)"
189- (File_kind. to_string file_kind)
190- (File_kind. to_string_hum file_kind))
191- in
192- Right (target, error)
193- | Unix_error (error , syscall , arg ) ->
194- let unix_error = Unix_error.Detailed. create error ~syscall ~arg in
195- Right (target, Unix_error.Detailed. pp unix_error)
196- | Unrecognized exn ->
197- let error =
198- Pp. verbatim
199- (match exn with
200- | Sys_error msg ->
201- let prefix =
202- let expected_syscall_path = Path. to_string (Path. build target) in
203- expected_syscall_path ^ " : "
204- in
205- String. drop_prefix_if_exists ~prefix msg
206- | exn -> Printexc. to_string exn )
207- in
208- Right (target, error)
176+ if Cached_digest.Digest_result.Error. no_such_file error
177+ then Left target
178+ else (
179+ let error = Cached_digest.Digest_result.Error. pp error (Path. build target) in
180+ Right (target, error))
209181 in
210182 Nonempty_list. to_list errors |> List. partition_map ~f: process_target
211183 in
Original file line number Diff line number Diff line change @@ -189,6 +189,36 @@ module Digest_result = struct
189189 | Unix_error of Unix_error.Detailed .t
190190 | Unrecognized of exn
191191
192+ let no_such_file = function
193+ | No_such_file -> true
194+ | _ -> false
195+ ;;
196+
197+ let pp t path =
198+ match t with
199+ | No_such_file -> Pp. verbatim " No such file"
200+ | Broken_symlink -> Pp. verbatim " Broken symbolic link"
201+ | Cyclic_symlink -> Pp. verbatim " Cyclic symbolic link"
202+ | Unexpected_kind file_kind ->
203+ Pp. verbatimf
204+ " Unexpected file kind %S (%s)"
205+ (File_kind. to_string file_kind)
206+ (File_kind. to_string_hum file_kind)
207+ | Unix_error (error , syscall , arg ) ->
208+ let unix_error = Unix_error.Detailed. create error ~syscall ~arg in
209+ Unix_error.Detailed. pp unix_error
210+ | Unrecognized exn ->
211+ Pp. verbatim
212+ (match exn with
213+ | Sys_error msg ->
214+ let prefix =
215+ let expected_syscall_path = Path. to_string path in
216+ expected_syscall_path ^ " : "
217+ in
218+ String. drop_prefix_if_exists ~prefix msg
219+ | exn -> Printexc. to_string exn )
220+ ;;
221+
192222 let equal x y =
193223 match x, y with
194224 | No_such_file , No_such_file -> true
Original file line number Diff line number Diff line change @@ -4,14 +4,10 @@ open Import
44
55module Digest_result : sig
66 module Error : sig
7- type t =
8- | No_such_file
9- | Broken_symlink
10- | Cyclic_symlink
11- | Unexpected_kind of File_kind .t
12- | Unix_error of Unix_error.Detailed .t (* * Can't be [ENOENT]. *)
13- | Unrecognized of exn
7+ type t
148
9+ val no_such_file : t -> bool
10+ val pp : t -> Path .t -> _ Pp .t
1511 val to_dyn : t -> Dyn .t
1612 end
1713
Original file line number Diff line number Diff line change @@ -316,16 +316,12 @@ let file_digest_exn ?loc path =
316316 file_digest path
317317 >> = function
318318 | Ok digest -> Memo. return digest
319- | Error No_such_file -> report_user_error []
320- | Error Broken_symlink -> report_user_error [ Pp. text " Broken symbolic link" ]
321- | Error Cyclic_symlink -> report_user_error [ Pp. text " Cyclic symbolic link" ]
322- | Error (Unexpected_kind st_kind ) ->
323- report_user_error
324- [ Pp. textf " This is not a regular file (%s)" (File_kind. to_string st_kind) ]
325- | Error (Unix_error unix_error ) ->
326- report_user_error [ Unix_error.Detailed. pp_reason unix_error ]
327- | Error (Unrecognized exn ) ->
328- report_user_error [ Pp. textf " %s" (Printexc. to_string exn ) ]
319+ | Error e ->
320+ if Cached_digest.Digest_result.Error. no_such_file e
321+ then report_user_error []
322+ else
323+ report_user_error
324+ [ Cached_digest.Digest_result.Error. pp e (Path. outside_build_dir path) ]
329325;;
330326
331327let dir_contents ?(force_update = false ) path =
You can’t perform that action at this time.
0 commit comments