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

Don't exit in library code #400

Merged
merged 9 commits into from
Dec 4, 2019
Merged

Conversation

Julow
Copy link
Collaborator

@Julow Julow commented Dec 3, 2019

Refactor error reporting to avoid exiting the program in library code.
Errors are propagated back to odoc/bin/main.ml by value and handled in an unified way.

Most of the changes are trivial but the patch is very invasive, exiting functions were very deep in the program.
Using exceptions can make the patch a little smaller but also harder as all exposed functions would need to catch them and there is a lot of them.

The exit status for some errors (marshalling) is now 1 instead of 2. Is that an issue ?

I added the Or_error module that re-export result and define a bind operator. I didn't use rresult as it was removed in #306.

Only the first commit is required for #398

let resolve = Resolve.resolve
let resolve resolver unit =
try Ok (Resolve.resolve resolver unit)
with Fetch_failed (`Msg _ as e) -> Error e
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use an exception to propagate errors inside the resolver. This is to avoid a giant refactor and potentially making it slower.

@aantron aantron merged commit 83f5570 into ocaml:master Dec 4, 2019
@aantron
Copy link
Contributor

aantron commented Dec 4, 2019

Thanks!

jonludlam added a commit to jonludlam/opam-repository that referenced this pull request Feb 7, 2020
CHANGES:

Additions

- Add option to turn warnings into errors (ocaml/odoc#398, Jules Aguillon)

Bugs fixed

- Emit quote before identifier in alias type expr (Fixes ocaml/odoc#391, Anton Bachin)
- Handle generalized open statements introduced in 4.08 (ocaml/odoc#393, Jon Ludlam)
- Refactor error reporting to avoid exiting the program in library code
  (ocaml/odoc#400, Jules Aguillon)
- Build on OCaml 4.10 (ocaml/odoc#408, Jon Ludlam)
mgree pushed a commit to mgree/opam-repository that referenced this pull request Feb 19, 2020
CHANGES:

Additions

- Add option to turn warnings into errors (ocaml/odoc#398, Jules Aguillon)

Bugs fixed

- Emit quote before identifier in alias type expr (Fixes ocaml/odoc#391, Anton Bachin)
- Handle generalized open statements introduced in 4.08 (ocaml/odoc#393, Jon Ludlam)
- Refactor error reporting to avoid exiting the program in library code
  (ocaml/odoc#400, Jules Aguillon)
- Build on OCaml 4.10 (ocaml/odoc#408, Jon Ludlam)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants