git.annexia.org
/
ocaml-libvirt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c27caca
)
Register a custom exception printer
author
Pino Toscano
<ptoscano@redhat.com>
Thu, 30 Aug 2018 10:13:42 +0000
(12:13 +0200)
committer
Richard W.M. Jones
<rjones@redhat.com>
Thu, 30 Aug 2018 10:26:32 +0000
(11:26 +0100)
This way all the users of ocaml-libvirt can use Printexc.to_string to
print a Virterror exception, even in case they do not catch it
explicitly.
libvirt/libvirt.ml
patch
|
blob
|
history
diff --git
a/libvirt/libvirt.ml
b/libvirt/libvirt.ml
index
8049f42
..
c03032f
100644
(file)
--- a/
libvirt/libvirt.ml
+++ b/
libvirt/libvirt.ml
@@
-1616,4
+1616,9
@@
let () =
"ocaml_libvirt_virterror" (Virterror (Virterror.no_error ()));
Callback.register_exception
"ocaml_libvirt_not_supported" (Not_supported "");
- c_init ()
+ c_init ();
+ Printexc.register_printer (
+ function
+ | Virterror e -> Some (Virterror.to_string e)
+ | _ -> None
+ )