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:
Zalim Bashorov
2016-11-14 22:36:49 +03:00
parent 1f4d95eaa7
commit aa2a4f0794
10 changed files with 114 additions and 40 deletions
@@ -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"
}