aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/bindings.cpp
diff options
context:
space:
mode:
authorGravatar zhiyuan <32867472+zhiyuang@users.noreply.github.com> 2022-10-20 16:40:58 +0800
committerGravatar GitHub <noreply@github.com> 2022-10-20 01:40:58 -0700
commit210ae2ffb2ef960d795fd785b69ea11379590e4f (patch)
tree2b0042000178f781913eaa582713bbd43f8ae6eb /src/bun.js/bindings/bindings.cpp
parent9f16906499c812eb82a982307511c454dec769ed (diff)
downloadbun-210ae2ffb2ef960d795fd785b69ea11379590e4f.tar.gz
bun-210ae2ffb2ef960d795fd785b69ea11379590e4f.tar.zst
bun-210ae2ffb2ef960d795fd785b69ea11379590e4f.zip
Fix Bun.serve error handler error param (#1359)
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
-rw-r--r--src/bun.js/bindings/bindings.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 0cba2185d..d0de85849 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -2556,6 +2556,20 @@ void JSC__JSValue__getNameProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* a
arg2->len = 0;
}
+JSC__JSValue JSC__JSValue__toError(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ if (JSC::Exception* jscException = JSC::jsDynamicCast<JSC::Exception*>(value)) {
+ if (JSC::ErrorInstance* error = JSC::jsDynamicCast<JSC::ErrorInstance*>(jscException->value())) {
+ return JSC::JSValue::encode(JSC::JSValue(error));
+ }
+ }
+ if (JSC::ErrorInstance* error = JSC::jsDynamicCast<JSC::ErrorInstance*>(value)) {
+ return JSC::JSValue::encode(JSC::JSValue(error));
+ }
+ return JSC::JSValue::encode(JSC::jsUndefined());
+}
+
void JSC__JSValue__toZigException(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
ZigException* exception)
{