Make Throwable.printStackTrace() common
#KT-38044
This commit is contained in:
@@ -130,6 +130,12 @@ internal class KotlinNothingValueException : RuntimeException {
|
|||||||
@SinceKotlin("1.4")
|
@SinceKotlin("1.4")
|
||||||
public expect fun Throwable.stackTraceToString(): String
|
public expect fun Throwable.stackTraceToString(): String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the [detailed description][Throwable.stackTraceToString] of this throwable to the standard output or standard error output.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.4")
|
||||||
|
public expect fun Throwable.printStackTrace(): Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When supported by the platform, adds the specified exception to the list of exceptions that were
|
* When supported by the platform, adds the specified exception to the list of exceptions that were
|
||||||
* suppressed in order to deliver this exception.
|
* suppressed in order to deliver this exception.
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ package kotlin
|
|||||||
@SinceKotlin("1.4")
|
@SinceKotlin("1.4")
|
||||||
public actual fun Throwable.stackTraceToString(): String = ExceptionTraceBuilder().buildFor(this)
|
public actual fun Throwable.stackTraceToString(): String = ExceptionTraceBuilder().buildFor(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the [detailed description][Throwable.stackTraceToString] of this throwable to console error output.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.4")
|
||||||
|
public actual fun Throwable.printStackTrace() {
|
||||||
|
console.error(this.stackTraceToString())
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified exception to the list of exceptions that were
|
* Adds the specified exception to the list of exceptions that were
|
||||||
* suppressed in order to deliver this exception.
|
* suppressed in order to deliver this exception.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import kotlin.internal.*
|
|||||||
*/
|
*/
|
||||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available
|
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun Throwable.printStackTrace(): Unit = (this as java.lang.Throwable).printStackTrace()
|
public actual inline fun Throwable.printStackTrace(): Unit = (this as java.lang.Throwable).printStackTrace()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the [detailed description][Throwable.stackTraceToString] of this throwable to the specified [writer].
|
* Prints the [detailed description][Throwable.stackTraceToString] of this throwable to the specified [writer].
|
||||||
|
|||||||
Reference in New Issue
Block a user