Skip to content
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

Warn instead of failing on opam files #2023

Merged
merged 1 commit into from
Apr 8, 2019
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ unreleased
- Do not list private modules in the generated index. (#2009, fix #2008,
@rgrinberg)

- Warn instead of failing if an opam file fails to parse. This opam file can
still be used to define scope. (#2023, @rgrinberg)

1.8.2 (10/03/2019)
------------------

Expand Down
18 changes: 15 additions & 3 deletions src/dune_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,21 @@ let load ~dir ~files =
match Filename.split_extension fn with
| (pkg, ".opam") when pkg <> "" ->
let version_from_opam_file =
let opam = Opam_file.load (Path.relative dir fn) in
match Opam_file.get_field opam "version" with
| Some (String (_, s)) -> Some s
let open Option.O in
let* opam =
let opam_file = Path.relative dir fn in
match Opam_file.load opam_file with
| s -> Some s
| exception exn ->
Errors.warn (Loc.in_file opam_file)
"Unable to read opam file. This package's version field will\
be [email protected]: %a@."
Exn.pp exn;
None
in
let* version = Opam_file.get_field opam "version" in
match version with
| String (_, s) -> Some s
| _ -> None
in
let name = Package.Name.of_string pkg in
Expand Down
5 changes: 4 additions & 1 deletion src/stdune/exn.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ let pp_uncaught ~backtrace fmt exn =
| @{<error>Internal error@}: Uncaught exception.\n\
%s\n\
\\%s@."
line s line;
line s line

let pp fmt exn =
Format.pp_print_string fmt (Printexc.to_string exn)

include
((struct
Expand Down
2 changes: 2 additions & 0 deletions src/stdune/exn.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ val protectx : 'a -> f:('a -> 'b) -> finally:('a -> unit) -> 'b

val pp_uncaught : backtrace:string -> Format.formatter -> t -> unit

val pp : Format.formatter -> t -> unit

val raise_with_backtrace: exn -> Printexc.raw_backtrace -> _

val equal : t -> t -> bool
Expand Down