KJS: implement Throwable in Kotlin instead of use it as alias of JS Error
* Make it an inheritor of JS Error. Otherwise, Chakra engine doesn't fill stack trace of exception; In other engines inheritance has some good effects too. * Copy all properties from internally created instance of JS Error #KT-6985 Fixed #KT-2328 Fixed #KT-8019 Fixed #KT-10911 Fixed
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package foo
|
||||
|
||||
class MyException(m: String? = null): Exception(m)
|
||||
class MyException2(m: String? = null): Throwable(m)
|
||||
|
||||
fun check(e: Throwable, expectedString: String) {
|
||||
try {
|
||||
throw e
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
assertEquals(expectedString, e.toString())
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check(Throwable(), "Throwable: null")
|
||||
check(Throwable("ccc"), "Throwable: ccc")
|
||||
check(Exception(), "Exception: null")
|
||||
check(Exception("bbb"), "Exception: bbb")
|
||||
check(MyException(), "MyException: null")
|
||||
check(MyException("aaa"), "MyException: aaa")
|
||||
check(MyException2(), "MyException2: null")
|
||||
check(MyException2("aaa"), "MyException2: aaa")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user