Skip to content

Commit ae64f12

Browse files
authored
Merge pull request #64 from golemcloud/better-js-error-detection
Better JS Error detection
2 parents 515e0e8 + 4d1d52c commit ae64f12

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/wasm-rquickjs/skeleton/src/internal.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,13 @@ pub fn format_js_exception(exc: &Value) -> String {
671671
}
672672

673673
pub fn try_format_js_error(err: &Value) -> Option<String> {
674+
let error_ctor: Object = err.ctx().globals().get("Error").ok()?;
674675
let obj = err.as_object()?;
676+
677+
if !obj.is_instance_of(error_ctor) {
678+
return None;
679+
}
680+
675681
let message: Option<String> = obj.get("message").ok();
676682
let stack: Option<String> = obj.get("stack").ok();
677683

0 commit comments

Comments
 (0)