val most_recent : unit -> t
most_recent () returns a backtrace containing the stack that was unwound by the most recently raised exception.
Normally this includes just the function calls that lead from the exception handler being set up to the exception being raised. However, due to inlining, the stack frame that has the exception handler may correspond to a chain of multiple function calls. All of those function calls are then reported in this backtrace, even though they are not themselves on the path from the exception handler to the "raise".
most_recent_for_exn exn returns a backtrace containing the stack that was unwound when raising
exn is the most recently raised exception. Otherwise it returns
Note that this may return a misleading backtrace instead of
None if different raise events happen to raise physically equal exceptions. Consider the example below. Here if
e = Not_found and
Not_found internally then the backtrace will correspond to the internal backtrace in
g instead of the one used in
f, which is not desirable.
try f () with | e -> g (); let bt = Backtrace.Exn.most_recent_for_exn e in ...