Skip to content

Commit

Permalink
More consise error message printing
Browse files Browse the repository at this point in the history
  • Loading branch information
gridbugs committed Feb 22, 2023
1 parent 347c7b7 commit 9cc963c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/dev_repo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type t = string
let compare = String.compare
let from_string s = s
let to_string t = t
let pp fmt t = Format.fprintf fmt "%s" t
let pp = Fmt.string

let rec repeat_while_some x ~f =
match f x with None -> x | Some x -> repeat_while_some x ~f
Expand Down
18 changes: 7 additions & 11 deletions lib/duniverse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,16 @@ let dev_repo_package_map_to_repos dev_repo_package_map =
| Some (dir, dev_repos) ->
let dir_path = Fpath.(Config.vendor_dir / dir) in
let message_first_line =
Format.asprintf
"Multiple dev-repos would be vendored into the directory: %a"
Fmt.str "Multiple dev-repos would be vendored into the directory: %a"
Fpath.pp dir_path
in
let message_dev_repos =
Format.sprintf "Dev-repos:\n%s"
(List.map dev_repos ~f:(fun dev_repo ->
Format.asprintf "- %a" Dev_repo.pp dev_repo)
|> String.concat ~sep:"\n")
let dev_repos_pp =
Fmt.list
~sep:Fmt.(const char '\n')
(fun ppf dev_repo -> Fmt.pf ppf "- %a" Dev_repo.pp dev_repo)
in
let message =
[ message_first_line; message_dev_repos ] |> String.concat ~sep:"\n"
in
Error (`Msg message)
Rresult.R.error_msgf "%s\nDev-repos:\n%a" message_first_line
dev_repos_pp dev_repos
in
Ok (List.map ~f:snd repo_by_dev_repo)

Expand Down

0 comments on commit 9cc963c

Please sign in to comment.