js-on-sx: object literal __proto__ + try/catch error wrapping
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s

This commit is contained in:
2026-05-08 22:13:17 +00:00
parent 0d9c45176b
commit a1030dce5d
3 changed files with 58 additions and 2 deletions

View File

@@ -991,6 +991,34 @@
(define SuppressedError :js-undefined)
(define
js-str-startswith?
(fn
(s prefix)
(cond
((< (len s) (len prefix)) false)
(else (= (js-string-slice s 0 (len prefix)) prefix)))))
(define
js-wrap-exn
(fn
(e)
(cond
((not (= (type-of e) "string")) e)
((js-str-startswith? e "Undefined symbol:")
(js-new-call ReferenceError (js-args e)))
((js-str-startswith? e "TypeError:")
(js-new-call TypeError (js-args (js-string-slice e 11 (len e)))))
((js-str-startswith? e "RangeError:")
(js-new-call RangeError (js-args (js-string-slice e 12 (len e)))))
((js-str-startswith? e "SyntaxError:")
(js-new-call SyntaxError (js-args (js-string-slice e 13 (len e)))))
((js-str-startswith? e "ReferenceError:")
(js-new-call ReferenceError (js-args (js-string-slice e 16 (len e)))))
((js-str-startswith? e "URIError:")
(js-new-call URIError (js-args (js-string-slice e 10 (len e)))))
(else e))))
(define
js-date-from-one
(fn
@@ -3194,7 +3222,12 @@
(define
js-make-obj
(fn () (let ((d (dict))) (begin (dict-set! d "__js_order__" (list)) d))))
(fn ()
(let ((d (dict)))
(begin
(dict-set! d "__js_order__" (list))
(dict-set! d "__proto__" (get Object "prototype"))
d))))
(define
js-obj-order-add!