@@ -1180,44 +1180,26 @@ pub const Interpreter = struct {
1180
1180
}
1181
1181
};
1182
1182
1183
- pub fn createShellInterpreter(
1184
- globalThis: *JSC.JSGlobalObject,
1185
- callframe: *JSC.CallFrame,
1186
- ) bun.JSError!JSValue {
1183
+ pub fn createShellInterpreter(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
1187
1184
const allocator = bun.default_allocator;
1188
1185
const arguments_ = callframe.arguments(3);
1189
1186
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
1190
1187
1191
- const resolve = arguments.nextEat() orelse {
1192
- globalThis.throw("shell: expected 3 arguments, got 0", .{});
1193
- return .undefined;
1194
- };
1188
+ const resolve = arguments.nextEat() orelse return globalThis.throw2("shell: expected 3 arguments, got 0", .{});
1195
1189
1196
- const reject = arguments.nextEat() orelse {
1197
- globalThis.throw("shell: expected 3 arguments, got 0", .{});
1198
- return .undefined;
1199
- };
1190
+ const reject = arguments.nextEat() orelse return globalThis.throw2("shell: expected 3 arguments, got 0", .{});
1200
1191
1201
- const parsed_shell_script_js = arguments.nextEat() orelse {
1202
- globalThis.throw("shell: expected 3 arguments, got 0", .{});
1203
- return .undefined;
1204
- };
1192
+ const parsed_shell_script_js = arguments.nextEat() orelse return globalThis.throw2("shell: expected 3 arguments, got 0", .{});
1205
1193
1206
- const parsed_shell_script = parsed_shell_script_js.as(ParsedShellScript) orelse {
1207
- globalThis.throw("shell: expected a ParsedShellScript", .{});
1208
- return .undefined;
1209
- };
1194
+ const parsed_shell_script = parsed_shell_script_js.as(ParsedShellScript) orelse return globalThis.throw2("shell: expected a ParsedShellScript", .{});
1210
1195
1211
1196
var shargs: *ShellArgs = undefined;
1212
1197
var jsobjs: std.ArrayList(JSValue) = std.ArrayList(JSValue).init(allocator);
1213
1198
var quiet: bool = false;
1214
1199
var cwd: ?bun.String = null;
1215
1200
var export_env: ?EnvMap = null;
1216
1201
1217
- if (parsed_shell_script.args == null) {
1218
- globalThis.throw("shell: shell args is null, this is a bug in Bun. Please file a GitHub issue.", .{});
1219
- return .undefined;
1220
- }
1202
+ if (parsed_shell_script.args == null) return globalThis.throw2("shell: shell args is null, this is a bug in Bun. Please file a GitHub issue.", .{});
1221
1203
1222
1204
parsed_shell_script.take(
1223
1205
globalThis,
@@ -1248,8 +1230,7 @@ pub const Interpreter = struct {
1248
1230
if (export_env) |*ee| ee.deinit();
1249
1231
if (cwd) |*cc| cc.deref();
1250
1232
shargs.deinit();
1251
- throwShellErr(e, .{ .js = globalThis.bunVM().event_loop });
1252
- return .zero;
1233
+ return try throwShellErr(e, .{ .js = globalThis.bunVM().event_loop });
1253
1234
},
1254
1235
};
1255
1236
@@ -1259,7 +1240,7 @@ pub const Interpreter = struct {
1259
1240
if (cwd) |*cc| cc.deref();
1260
1241
shargs.deinit();
1261
1242
interpreter.finalize();
1262
- return .zero ;
1243
+ return error.JSError ;
1263
1244
}
1264
1245
1265
1246
interpreter.flags.quiet = quiet;
@@ -1472,8 +1453,7 @@ pub const Interpreter = struct {
1472
1453
null,
1473
1454
)) {
1474
1455
.err => |*e| {
1475
- throwShellErr(e, .{ .mini = mini });
1476
- return 1;
1456
+ e.throwMini();
1477
1457
},
1478
1458
.result => |i| i,
1479
1459
};
@@ -1542,8 +1522,7 @@ pub const Interpreter = struct {
1542
1522
null,
1543
1523
)) {
1544
1524
.err => |*e| {
1545
- throwShellErr(e, .{ .mini = mini });
1546
- return 1;
1525
+ e.throwMini();
1547
1526
},
1548
1527
.result => |i| i,
1549
1528
};
@@ -1643,8 +1622,7 @@ pub const Interpreter = struct {
1643
1622
if (this.setupIOBeforeRun().asErr()) |e| {
1644
1623
defer this.deinitEverything();
1645
1624
const shellerr = bun.shell.ShellErr.newSys(e);
1646
- throwShellErr(&shellerr, .{ .js = globalThis.bunVM().event_loop });
1647
- return .undefined;
1625
+ return try throwShellErr(&shellerr, .{ .js = globalThis.bunVM().event_loop });
1648
1626
}
1649
1627
incrPendingActivityFlag(&this.has_pending_activity);
1650
1628
@@ -2766,7 +2744,7 @@ pub const Interpreter = struct {
2766
2744
}
2767
2745
2768
2746
pub fn throw(this: *const State, err: *const bun.shell.ShellErr) void {
2769
- throwShellErr(err, this.eventLoop());
2747
+ throwShellErr(err, this.eventLoop()) catch {}; //TODO:
2770
2748
}
2771
2749
2772
2750
pub fn rootIO(this: *const State) *const IO {
@@ -5745,7 +5723,7 @@ pub const Interpreter = struct {
5745
5723
}
5746
5724
5747
5725
pub inline fn throw(this: *const Builtin, err: *const bun.shell.ShellErr) void {
5748
- this.parentCmd().base.throw(err);
5726
+ this.parentCmd().base.throw(err) catch {} ;
5749
5727
}
5750
5728
5751
5729
pub inline fn parentCmd(this: *const Builtin) *const Cmd {
@@ -12216,11 +12194,13 @@ inline fn fastMod(val: anytype, comptime rhs: comptime_int) @TypeOf(val) {
12216
12194
return val & (rhs - 1);
12217
12195
}
12218
12196
12219
- fn throwShellErr(e: *const bun.shell.ShellErr, event_loop: JSC.EventLoopHandle) void {
12220
- switch (event_loop) {
12197
+ /// 'js' event loop will always return JSError
12198
+ /// 'mini' event loop will always return noreturn and exit 1
12199
+ fn throwShellErr(e: *const bun.shell.ShellErr, event_loop: JSC.EventLoopHandle) bun.JSError!noreturn {
12200
+ return switch (event_loop) {
12221
12201
.mini => e.throwMini(),
12222
12202
.js => e.throwJS(event_loop.js.global),
12223
- }
12203
+ };
12224
12204
}
12225
12205
12226
12206
pub const ReadChunkAction = enum {
0 commit comments