ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 353 forks source link

UI improvement, error messages show OCaml exceptions/objects #5954

Open patrick-nicodemus opened 4 months ago

patrick-nicodemus commented 4 months ago

This is just an appearance thing, so it's relatively minor but I think worth posting in case anyone else thinks it's worth changing.

On a failed download attempt I get the following error messages:

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "coq-released":
        OpamDownload.Download_fail(_, "Curl failed: \"/usr/bin/curl --write-out
        %{http_code}\\\\n --retry 3 --retry-delay 2 --user-agent opam/2.1.5 -L
        -o /tmp/opam-4594-455670/index.tar.gz.part --
        https://coq.inria.fr/opam/released/index.tar.gz\" exited with code 6")
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_,
        "Curl failed: \"/usr/bin/curl --write-out %{http_code}\\\\n --retry 3
        --retry-delay 2 --user-agent opam/2.1.5 -L -o
        /tmp/opam-4594-679cce/index.tar.gz.part --
        https://opam.ocaml.org/index.tar.gz\" exited with code 6")

The messages are not hard to read and understand but it seems like the raw exception itself being leaked to the end user is not clean. I think this should be pretty-printed somehow. It also doesn't seem great that %{http-code} is in the error message instead of the actual http code that was used. Is this a necessary difficulty with dealing with format strings in error handling or can the actual http code be shown to the user?