Skip to content

Commit a7ff4cd

Browse files
committed
backtrace: keep old backtraces on reraise
The doccoment makes it look like the backtrace is kept, but this is not the case. Use is_important to make sure this happens. Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent b77aca2 commit a7ff4cd

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/backtrace.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ let get exn =
246246
|> Option.fold ~some:(fun tbl -> get tbl exn) ~none:empty
247247

248248
let reraise old newexn =
249+
is_important old;
249250
add newexn (remove old);
250251
raise newexn
251252

test/reraise.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
$ ./raiser.exe -reraise
77
Backtrace lab failed with exception Failure("bar")
88
Raised Failure("bar")
9-
1/2 raiser.exe Raised at file lib/backtrace.ml, line 250
10-
2/2 raiser.exe Called from file test/log.ml, line 55
9+
1/4 raiser.exe Raised at file test/raiser.ml, line 1
10+
2/4 raiser.exe Called from file test/raiser.ml, line 4
11+
3/4 raiser.exe Called from file lib/backtrace.ml, line 251
12+
4/4 raiser.exe Called from file test/log.ml, line 55
1113

1214

1315
$ ./raiser.exe -v1-with-backtrace

0 commit comments

Comments
 (0)