Skip to content

Commit

Permalink
refactor(pkg): remove an unnecessary [result] variable
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: cec60771-985f-423e-8258-bff703baba20 -->
  • Loading branch information
rgrinberg committed Jan 9, 2024
1 parent bf3ac2f commit ac745f7
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/dune_pkg/opam_solver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -617,24 +617,22 @@ let opam_package_to_lock_file_pkg
;;

let solve_package_list packages context =
let* result =
Fiber.collect_errors (fun () ->
(* [Solver.solve] returns [Error] when it's unable to find a solution to
the dependencies, but can also raise exceptions, for example if opam
is unable to parse an opam file in the package repository. To prevent
an unexpected opam exception from crashing dune, we catch all
exceptions raised by the solver and report them as [User_error]s
instead. *)
Solver.solve context packages)
>>| function
| Ok (Ok res) -> Ok res
| Ok (Error e) -> Error (`Diagnostics e)
| Error [] -> assert false
| Error (exn :: _) ->
(* CR-rgrinberg: this needs to be handled right *)
Error (`Exn exn.exn)
in
match result with
Fiber.collect_errors (fun () ->
(* [Solver.solve] returns [Error] when it's unable to find a solution to
the dependencies, but can also raise exceptions, for example if opam
is unable to parse an opam file in the package repository. To prevent
an unexpected opam exception from crashing dune, we catch all
exceptions raised by the solver and report them as [User_error]s
instead. *)
Solver.solve context packages)
>>| (function
| Ok (Ok res) -> Ok res
| Ok (Error e) -> Error (`Diagnostics e)
| Error [] -> assert false
| Error (exn :: _) ->
(* CR-rgrinberg: this needs to be handled right *)
Error (`Exn exn.exn))
>>= function
| Error (`Exn exn) ->
(match exn with
| OpamPp.(Bad_format _ | Bad_format_list _ | Bad_version _) as bad_format ->
Expand Down

0 comments on commit ac745f7

Please sign in to comment.