Replace catch bun.outOfMemory() with safer alternatives (#22141)

Replace `catch bun.outOfMemory()`, which can accidentally catch
non-OOM-related errors, with either `bun.handleOom` or a manual `catch
|err| switch (err)`.

(For internal tracking: fixes STAB-1070)

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
This commit is contained in:
taylor.fish
2025-08-26 12:50:25 -07:00
committed by GitHub
parent 300f486125
commit 437e15bae5
284 changed files with 1835 additions and 1662 deletions

View File

@@ -352,7 +352,7 @@ pub fn getQueriesArray(this: *const @This()) JSValue {
return js.queriesGetCached(this.js_value) orelse .zero;
}
pub fn failFmt(this: *@This(), error_code: AnyMySQLError.Error, comptime fmt: [:0]const u8, args: anytype) void {
const message = std.fmt.allocPrint(bun.default_allocator, fmt, args) catch bun.outOfMemory();
const message = bun.handleOom(std.fmt.allocPrint(bun.default_allocator, fmt, args));
defer bun.default_allocator.free(message);
const err = AnyMySQLError.mysqlErrorToJS(this.globalObject, message, error_code);