Skip to content
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ script: bash -ex ./.travis-docker.sh
env:
global:
- PINS="stdext:. xapi-stdext:. xapi-stdext-base64:. xapi-stdext-bigbuffer:. xapi-stdext-date:. xapi-stdext-deprecated:. xapi-stdext-encodings:. xapi-stdext-monadic:. xapi-stdext-pervasives:. xapi-stdext-range:. xapi-stdext-std:. xapi-stdext-threads:. xapi-stdext-unix:. xapi-stdext-zerocheck:."
- OCAML_VERSION=4.06.0
- DISTRO="ubuntu-16.04"
- TEST=false
- BASE_REMOTE="https://github.com/xapi-project/xs-opam"
matrix:
- PACKAGE=xapi-stdext OCAML_VERSION=4.04.2 \
- PACKAGE=xapi-stdext \
POST_INSTALL_HOOK="opam install alcotest; env TRAVIS=$TRAVIS TRAVIS_JOB_ID=$TRAVIS_JOB_ID bash -ex coverage.sh"
- PACKAGE=stdext OCAML_VERSION=4.04.2 REVDEPS=true
- PACKAGE=xapi-stdext OCAML_VERSION=4.06.0
- PACKAGE=stdext REVDEPS=true
matrix:
fast_finish: true
allow_failures:
Expand Down
4 changes: 3 additions & 1 deletion lib/xapi-stdext-pervasives/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
(library
((name xapi_stdext_pervasives)
(public_name xapi-stdext-pervasives)
(libraries (xapi-backtrace))
(libraries
(logs
xapi-backtrace))
))
11 changes: 10 additions & 1 deletion lib/xapi-stdext-pervasives/pervasiveext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@
* Even if fct raises an exception, clean_f is applied
*)

let src = Logs.Src.create "pervasiveext" ~doc:"logs from Xapi_stdext_pervasives.Pervasiveext"


let finally fct clean_f =
let result =
try
fct ();
with exn ->
Backtrace.is_important exn;
clean_f ();
begin
(* We catch and log exceptions raised by clean_f to avoid shadowing
the original exception raised by fct *)
try
clean_f ();
with cleanup_exn ->
Logs.warn ~src (fun m -> m "finally: Error while running cleanup after failure of main function: %s" (Printexc.to_string cleanup_exn));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor: you could use %a and Fmt.exn instead of Printexc.to_string, but its fine either way, we're not using Fmt here yet, so no need to introduce it.

end;
raise exn in
clean_f ();
result
Expand Down
1 change: 1 addition & 0 deletions xapi-stdext-pervasives.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ build: [[ "jbuilder" "build" "-p" name "-j" jobs ]]

depends: [
"jbuilder" {build}
"logs"
"xapi-backtrace"
]