mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
handle scope exceptions
This commit is contained in:
@@ -2266,7 +2266,7 @@ pub fn NewServer(protocol_enum: enum { http, https }, development_kind: enum { d
|
||||
return .{
|
||||
.js_request = switch (create_js_request) {
|
||||
.yes => request_object.toJS(this.globalThis),
|
||||
.bake => request_object.toJSForBake(this.globalThis, req),
|
||||
.bake => request_object.toJSForBake(this.globalThis, req) catch |err| this.globalThis.takeException(err),
|
||||
.no => .zero,
|
||||
},
|
||||
.request_object = request_object,
|
||||
|
||||
@@ -22,14 +22,16 @@ extern "C" JSC::EncodedJSValue Bun__JSRequest__createFromUwsReqForBake(Zig::Glob
|
||||
auto& vm = globalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
auto* structure = globalObject->m_JSBunRequestStructure.get(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
|
||||
// the params are passed into the page component as a prop so we'll make
|
||||
// this empty for now
|
||||
auto* emptyParams = JSC::constructEmptyObject(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
|
||||
JSBunRequest* request
|
||||
= JSBunRequest::create(vm, structure, requestPtr, emptyParams);
|
||||
scope.assertNoException();
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
|
||||
return JSValue::encode(request);
|
||||
}
|
||||
|
||||
@@ -179,8 +179,13 @@ pub fn toJS(this: *Request, globalObject: *JSGlobalObject) JSValue {
|
||||
}
|
||||
|
||||
extern "C" fn Bun__JSRequest__createFromUwsReqForBake(globalObject: *jsc.JSGlobalObject, requestPtr: *Request, req: *uws.Request) jsc.JSValue;
|
||||
pub fn toJSForBake(this: *Request, globalObject: *JSGlobalObject, req: *uws.Request) JSValue {
|
||||
return Bun__JSRequest__createFromUwsReqForBake(globalObject, this, req);
|
||||
pub fn toJSForBake(this: *Request, globalObject: *JSGlobalObject, req: *uws.Request) bun.JSError!JSValue {
|
||||
return bun.jsc.fromJSHostCall(
|
||||
globalObject,
|
||||
@src(),
|
||||
Bun__JSRequest__createFromUwsReqForBake,
|
||||
.{ globalObject, this, req },
|
||||
);
|
||||
}
|
||||
|
||||
extern "JS" fn Bun__getParamsIfBunRequest(this_value: JSValue) JSValue;
|
||||
|
||||
Reference in New Issue
Block a user