Clean up some error handling code (#15368)

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
This commit is contained in:
Jarred Sumner
2024-11-25 15:42:02 -08:00
committed by GitHub
parent b19f13f5c4
commit 8ca0eb831d
11 changed files with 978 additions and 164 deletions

View File

@@ -706,10 +706,14 @@ pub const String = extern struct {
pub fn fromJS2(value: bun.JSC.JSValue, globalObject: *JSC.JSGlobalObject) bun.JSError!String {
var out: String = String.dead;
if (BunString__fromJS(globalObject, value, &out)) {
bun.assert(out.tag != .Dead);
if (comptime bun.Environment.isDebug) {
bun.assert(out.tag != .Dead);
}
return out;
} else {
bun.assert(globalObject.hasException());
if (comptime bun.Environment.isDebug) {
bun.assert(globalObject.hasException());
}
return error.JSError;
}
}
@@ -721,7 +725,9 @@ pub const String = extern struct {
if (BunString__fromJSRef(globalObject, value, &out)) {
return out;
} else {
bun.assert(globalObject.hasException());
if (comptime bun.Environment.isDebug) {
bun.assert(globalObject.hasException());
}
return error.JSError;
}
}