diff --git a/libraries/stdlib/wasm/builtins/kotlin/Throwable.kt b/libraries/stdlib/wasm/builtins/kotlin/Throwable.kt index 6f5ad876aaf..fd14cb7f1ce 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Throwable.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Throwable.kt @@ -28,6 +28,16 @@ public open class Throwable(open val message: String?, open val cause: kotlin.Th } internal var suppressedExceptionsList: MutableList? = null + + /** + * Returns the short description of this throwable consisting of the exception class name + * followed by the exception message if it is not null. + */ + public override fun toString(): String { + val kClass = this::class + val s = kClass.simpleName ?: "Throwable" + return if (message != null) s + ": " + message.toString() else s + } } @JsFun("() => new Error().stack")