mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
implement node:cluster (#11492)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: nektro <nektro@users.noreply.github.com> Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
This commit is contained in:
28
src/bun.js/node/node_error_binding.zig
Normal file
28
src/bun.js/node/node_error_binding.zig
Normal file
@@ -0,0 +1,28 @@
|
||||
const std = @import("std");
|
||||
const bun = @import("root").bun;
|
||||
const Environment = bun.Environment;
|
||||
const JSC = bun.JSC;
|
||||
const string = bun.string;
|
||||
const Output = bun.Output;
|
||||
const ZigString = JSC.ZigString;
|
||||
const createTypeError = JSC.JSGlobalObject.createTypeErrorInstanceWithCode;
|
||||
const createError = JSC.JSGlobalObject.createErrorInstanceWithCode;
|
||||
const createRangeError = JSC.JSGlobalObject.createRangeErrorInstanceWithCode;
|
||||
|
||||
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) callconv(JSC.conv) JSC.JSValue {
|
||||
const S = struct {
|
||||
fn cb(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
|
||||
_ = callframe;
|
||||
return createFn(globalThis, code, message, .{});
|
||||
}
|
||||
};
|
||||
return JSC.JSFunction.create(global, @tagName(code), S.cb, 0, .{});
|
||||
}
|
||||
};
|
||||
return R.cbb;
|
||||
}
|
||||
Reference in New Issue
Block a user