Skip to content

Don't backtrace on invalid input in compile-deps #1313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Fixed

- Fix bug causing stack overflow in odoc_driver_monorepo (@jonludlam, #1304)
- Fix backtrace on invalid input in compile-deps (@jonludlam, #1313)

# 3.0.0~beta1

Expand Down
32 changes: 23 additions & 9 deletions src/odoc/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,15 +1410,29 @@ end)
module Depends = struct
module Compile = struct
let list_dependencies input_files =
let deps =
Depends.for_compile_step (List.map ~f:Fs.File.of_string input_files)
in
List.iter
~f:(fun t ->
Printf.printf "%s %s\n" (Depends.Compile.name t)
(Digest.to_hex @@ Depends.Compile.digest t))
deps;
flush stdout
try
let deps =
Depends.for_compile_step (List.map ~f:Fs.File.of_string input_files)
in
List.iter
~f:(fun t ->
Printf.printf "%s %s\n" (Depends.Compile.name t)
(Digest.to_hex @@ Depends.Compile.digest t))
deps;
flush stdout
with Cmi_format.Error e ->
let msg =
match e with
| Not_an_interface file ->
Printf.sprintf "File %S is not an interface" file
| Wrong_version_interface (file, v) ->
Printf.sprintf "File %S is compiled for %s version of OCaml" file
v
| Corrupted_interface file ->
Printf.sprintf "File %S is corrupted" file
in
Printf.eprintf "ERROR: %s\n%!" msg;
exit 1

let cmd =
let input =
Expand Down