Skip to content

Commit 639116d

Browse files
committed
Fixed exception extraction bug
1 parent 0329139 commit 639116d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/sqlite3_stubs.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ static pthread_key_t user_exception_key;
113113

114114
typedef struct user_exception { value exn; } user_exception;
115115

116-
static inline void create_user_exception(value exn)
116+
static inline void create_user_exception(value v_exn)
117117
{
118118
user_exception *user_exn = malloc(sizeof(user_exception));
119-
user_exn->exn = exn;
119+
user_exn->exn = v_exn;
120120
caml_register_global_root(&user_exn->exn);
121121
pthread_setspecific(user_exception_key, user_exn);
122122
}
@@ -1049,10 +1049,11 @@ static inline value caml_sqlite3_wrap_values(int argc, sqlite3_value **args)
10491049
}
10501050
}
10511051

1052-
static inline void exception_result(sqlite3_context *ctx, value v_exn)
1052+
static inline void exception_result(sqlite3_context *ctx, value v_res)
10531053
{
1054-
sqlite3_result_error(ctx, "OCaml callback raised an exception", -1);
1054+
value v_exn = Extract_exception(v_res);
10551055
create_user_exception(v_exn);
1056+
sqlite3_result_error(ctx, "OCaml callback raised an exception", -1);
10561057
}
10571058

10581059
static inline void set_sqlite3_result(sqlite3_context *ctx, value v_res)

0 commit comments

Comments
 (0)