js-on-sx: Error/TypeError/etc return instance when called without new
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
This commit is contained in:
@@ -817,27 +817,34 @@
|
||||
((dict-has? obj "__proto__") (js-in-walk (get obj "__proto__") skey))
|
||||
(else false))))
|
||||
|
||||
(define
|
||||
js-error-init!
|
||||
(fn
|
||||
(this name args)
|
||||
(begin
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if (= (len args) 0) "" (js-to-string (nth args 0))))
|
||||
(dict-set! this "name" name)
|
||||
(dict-set! this "__js_error_data__" true)
|
||||
this)))
|
||||
|
||||
(define
|
||||
js-error-receiver
|
||||
(fn
|
||||
(ctor)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(cond
|
||||
((= (type-of this) "dict") this)
|
||||
(else (js-new-call ctor (list)))))))
|
||||
|
||||
(define
|
||||
Error
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= (type-of this) "dict")
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if
|
||||
(= (len args) 0)
|
||||
""
|
||||
(js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "Error")
|
||||
(dict-set! this "__js_error_data__" true))
|
||||
nil)
|
||||
this))))
|
||||
(js-error-init! (js-error-receiver Error) "Error" args)))
|
||||
|
||||
(define
|
||||
js-error-is-error
|
||||
@@ -868,124 +875,28 @@
|
||||
|
||||
(define
|
||||
TypeError
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= (type-of this) "dict")
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if
|
||||
(= (len args) 0)
|
||||
""
|
||||
(js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "TypeError")
|
||||
(dict-set! this "__js_error_data__" true))
|
||||
nil)
|
||||
this))))
|
||||
(fn (&rest args)
|
||||
(js-error-init! (js-error-receiver TypeError) "TypeError" args)))
|
||||
(define
|
||||
RangeError
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= (type-of this) "dict")
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if
|
||||
(= (len args) 0)
|
||||
""
|
||||
(js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "RangeError")
|
||||
(dict-set! this "__js_error_data__" true))
|
||||
nil)
|
||||
this))))
|
||||
(fn (&rest args)
|
||||
(js-error-init! (js-error-receiver RangeError) "RangeError" args)))
|
||||
(define
|
||||
SyntaxError
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= (type-of this) "dict")
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if
|
||||
(= (len args) 0)
|
||||
""
|
||||
(js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "SyntaxError")
|
||||
(dict-set! this "__js_error_data__" true))
|
||||
nil)
|
||||
this))))
|
||||
(fn (&rest args)
|
||||
(js-error-init! (js-error-receiver SyntaxError) "SyntaxError" args)))
|
||||
(define
|
||||
ReferenceError
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= (type-of this) "dict")
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if
|
||||
(= (len args) 0)
|
||||
""
|
||||
(js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "ReferenceError")
|
||||
(dict-set! this "__js_error_data__" true))
|
||||
nil)
|
||||
this))))
|
||||
(fn (&rest args)
|
||||
(js-error-init! (js-error-receiver ReferenceError) "ReferenceError" args)))
|
||||
(define
|
||||
URIError
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= this :js-undefined)
|
||||
nil
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if (empty? args) "" (js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "URIError")
|
||||
(dict-set! this "__js_error_data__" true)))
|
||||
this))))
|
||||
(fn (&rest args)
|
||||
(js-error-init! (js-error-receiver URIError) "URIError" args)))
|
||||
(define
|
||||
EvalError
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this (js-this)))
|
||||
(begin
|
||||
(if
|
||||
(= this :js-undefined)
|
||||
nil
|
||||
(do
|
||||
(dict-set!
|
||||
this
|
||||
"message"
|
||||
(if (empty? args) "" (js-to-string (nth args 0))))
|
||||
(dict-set! this "name" "EvalError")
|
||||
(dict-set! this "__js_error_data__" true)))
|
||||
this))))
|
||||
(fn (&rest args)
|
||||
(js-error-init! (js-error-receiver EvalError) "EvalError" args)))
|
||||
|
||||
(define AggregateError :js-undefined)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user