Files
bun.sh/src/bun.js/node/node_error_binding.zig
taylor.fish 07cd45deae Refactor Zig imports and file structure (part 1) (#21270)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-22 17:51:38 -07:00

26 lines
1.1 KiB
Zig

pub const ERR_INVALID_HANDLE_TYPE = createSimpleError(createTypeError, .ERR_INVALID_HANDLE_TYPE, "This handle type cannot be sent");
pub const ERR_CHILD_CLOSED_BEFORE_REPLY = createSimpleError(createError, .ERR_CHILD_CLOSED_BEFORE_REPLY, "Child closed before reply received");
fn createSimpleError(comptime createFn: anytype, comptime code: jsc.Node.ErrorCode, comptime message: string) jsc.JS2NativeFunctionType {
const R = struct {
pub fn cbb(global: *jsc.JSGlobalObject) bun.JSError!jsc.JSValue {
const S = struct {
fn cb(globalThis: *jsc.JSGlobalObject, callframe: *jsc.CallFrame) bun.JSError!jsc.JSValue {
_ = callframe;
return createFn(globalThis, code, message, .{});
}
};
return jsc.JSFunction.create(global, @tagName(code), S.cb, 0, .{});
}
};
return R.cbb;
}
const string = []const u8;
const bun = @import("bun");
const jsc = bun.jsc;
const createError = jsc.JSGlobalObject.createErrorInstanceWithCode;
const createTypeError = jsc.JSGlobalObject.createTypeErrorInstanceWithCode;