Skip to content

Commit 848c8dc

Browse files
committed
add error message when allocation fails
1 parent 7eaf6ec commit 848c8dc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ext/node/ops/sqlite/database.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,7 @@ unsafe fn get_aggregate_data(
13761376
) as *mut AggregateData;
13771377

13781378
if agg_ptr.is_null() {
1379+
sqlite_result_error(ctx, "Failed to allocate aggregate context");
13791380
return None;
13801381
}
13811382

@@ -1429,7 +1430,11 @@ unsafe fn custom_aggregate_step_base(
14291430
v8::tc_scope!(tc_scope, scope);
14301431

14311432
let Some(agg_ptr) = get_aggregate_data(ctx, data, tc_scope) else {
1432-
tc_scope.rethrow();
1433+
if tc_scope.has_caught() {
1434+
data.ignore_next_sqlite_error.set(true);
1435+
sqlite_result_error(ctx, "");
1436+
tc_scope.rethrow();
1437+
}
14331438
return;
14341439
};
14351440
let agg = &mut *agg_ptr;
@@ -1529,7 +1534,11 @@ unsafe fn custom_aggregate_value_base(
15291534
v8::tc_scope!(tc_scope, scope);
15301535

15311536
let Some(agg_ptr) = get_aggregate_data(ctx, data, tc_scope) else {
1532-
tc_scope.rethrow();
1537+
if tc_scope.has_caught() {
1538+
data.ignore_next_sqlite_error.set(true);
1539+
sqlite_result_error(ctx, "");
1540+
tc_scope.rethrow();
1541+
}
15331542
return;
15341543
};
15351544
let agg = &mut *agg_ptr;

0 commit comments

Comments
 (0)