mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Don't pass bare Exceptions to JS in node:net (#17639)
This commit is contained in:
@@ -1572,7 +1572,7 @@ fn NewSocket(comptime ssl: bool) type {
|
||||
const globalObject = handlers.globalObject;
|
||||
const this_value = this.getThisValue(globalObject);
|
||||
_ = callback.call(globalObject, this_value, &.{this_value}) catch |err| {
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeException(err) });
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeError(err) });
|
||||
};
|
||||
}
|
||||
pub fn onTimeout(
|
||||
@@ -1598,7 +1598,7 @@ fn NewSocket(comptime ssl: bool) type {
|
||||
const globalObject = handlers.globalObject;
|
||||
const this_value = this.getThisValue(globalObject);
|
||||
_ = callback.call(globalObject, this_value, &.{this_value}) catch |err| {
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeException(err) });
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeError(err) });
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1843,7 +1843,7 @@ fn NewSocket(comptime ssl: bool) type {
|
||||
const globalObject = handlers.globalObject;
|
||||
const this_value = this.getThisValue(globalObject);
|
||||
_ = callback.call(globalObject, this_value, &.{this_value}) catch |err| {
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeException(err) });
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeError(err) });
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1956,7 +1956,7 @@ fn NewSocket(comptime ssl: bool) type {
|
||||
this_value,
|
||||
js_error,
|
||||
}) catch |e| {
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeException(e) });
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeError(e) });
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1988,7 +1988,7 @@ fn NewSocket(comptime ssl: bool) type {
|
||||
this_value,
|
||||
output_value,
|
||||
}) catch |err| {
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeException(err) });
|
||||
_ = handlers.callErrorHandler(this_value, &.{ this_value, globalObject.takeError(err) });
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3247,7 +3247,20 @@ pub const JSGlobalObject = opaque {
|
||||
}
|
||||
|
||||
return this.tryTakeException() orelse {
|
||||
@panic("A JavaScript exception was thrown, however it was cleared before it could be read.");
|
||||
@panic("A JavaScript exception was thrown, but it was cleared before it could be read.");
|
||||
};
|
||||
}
|
||||
|
||||
pub fn takeError(this: *JSGlobalObject, proof: bun.JSError) JSValue {
|
||||
switch (proof) {
|
||||
error.JSError => {},
|
||||
error.OutOfMemory => this.throwOutOfMemory() catch {},
|
||||
}
|
||||
|
||||
return (this.tryTakeException() orelse {
|
||||
@panic("A JavaScript exception was thrown, but it was cleared before it could be read.");
|
||||
}).toError() orelse {
|
||||
@panic("Couldn't convert a JavaScript exception to an Error instance.");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user