JS IR: fix throwable descendants

^ KT-43490 fixed
This commit is contained in:
Anton Bannykh
2023-02-22 20:31:28 +01:00
committed by Space Team
parent 48ed6c4cc7
commit b0de442d76
3 changed files with 75 additions and 12 deletions
@@ -103,7 +103,8 @@ internal fun extendThrowable(this_: dynamic, message: String?, cause: Throwable?
}
internal fun setPropertiesToThrowableInstance(this_: dynamic, message: String?, cause: Throwable?) {
if (!hasOwnPrototypeProperty(this_, "message")) {
val errorInfo = calculateErrorInfo(JsObject.getPrototypeOf(this_))
if ((errorInfo and 0x1) == 0) {
@Suppress("IfThenToElvis")
this_.message = if (message == null) {
@Suppress("SENSELESS_COMPARISON")
@@ -116,7 +117,7 @@ internal fun setPropertiesToThrowableInstance(this_: dynamic, message: String?,
}
} else message
}
if (!hasOwnPrototypeProperty(this_, "cause")) {
if ((errorInfo and 0x2) == 0) {
this_.cause = cause
}
this_.name = JsObject.getPrototypeOf(this_).constructor.name