aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/bindings.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 47ef36aea..bff5640ef 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -1396,15 +1396,22 @@ BunString WebCore__DOMURL__fileSystemPath(WebCore__DOMURL* arg0)
extern "C" JSC__JSValue ZigString__toJSONObject(const ZigString* strPtr, JSC::JSGlobalObject* globalObject)
{
auto str = Zig::toString(*strPtr);
- auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm());
- auto scope = DECLARE_CATCH_SCOPE(globalObject->vm());
- JSValue result = JSONParseWithException(globalObject, str);
- if (auto* exception = scope.exception()) {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+
+ // JSONParseWithException does not propagate exceptions as expected. See #5859
+ JSValue result = JSONParse(globalObject, str);
+
+ if (!result && !scope.exception()) {
+ scope.throwException(globalObject, createSyntaxError(globalObject, "Failed to parse JSON"_s));
+ }
+
+ if (scope.exception()) {
+ auto* exception = scope.exception();
scope.clearException();
- RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(exception->value()));
+ return JSC::JSValue::encode(exception);
}
- RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+ return JSValue::encode(result);
}
JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0,