aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2014-01-30 15:30:01 +0100
committerPierre-Marie Pédrot2014-01-30 16:02:33 +0100
commit1059ecce2a2662e4d8f335bd4db743df70b100b1 (patch)
tree236cad1f42ecaea078f8a0fb17dd17eec81631e0 /lib
parenta5e78ef4a8450991c6f1ee748b720eb0d54d04d2 (diff)
Fixing backtrace handling here and there.
Diffstat (limited to 'lib')
-rw-r--r--lib/backtrace.ml13
-rw-r--r--lib/backtrace.mli7
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/backtrace.ml b/lib/backtrace.ml
index d64f42f7f0..19b07d8767 100644
--- a/lib/backtrace.ml
+++ b/lib/backtrace.ml
@@ -96,3 +96,16 @@ let add_backtrace e =
Exninfo.add e backtrace bt
end
else e
+
+let app_backtrace ~src ~dst =
+ if !is_recording then
+ match get_backtrace src with
+ | None -> dst
+ | Some bt ->
+ match get_backtrace dst with
+ | None ->
+ Exninfo.add dst backtrace bt
+ | Some nbt ->
+ let bt = bt @ nbt in
+ Exninfo.add dst backtrace bt
+ else dst
diff --git a/lib/backtrace.mli b/lib/backtrace.mli
index b5a956573d..ecd046b545 100644
--- a/lib/backtrace.mli
+++ b/lib/backtrace.mli
@@ -87,3 +87,10 @@ val add_backtrace : exn -> exn
I admit that's a bit heavy, but there is not much to do...
*)
+
+val app_backtrace : src:exn -> dst:exn -> exn
+(** Append the backtrace from [src] to [dst]. The returned exception is [dst]
+ except for its backtrace information. This is targeted at container
+ exceptions, that is, exceptions that contain exceptions. This way, one can
+ transfer the backtrace from the container to the underlying exception, as if
+ the latter was the one originally raised. *)