[Analysis API] do not create multiple attachments inside exceptions
This commit is contained in:
@@ -41,23 +41,6 @@ open class KotlinExceptionWithAttachments : RuntimeException, ExceptionWithAttac
|
||||
}
|
||||
|
||||
|
||||
fun KotlinExceptionWithAttachments.withAttachmentBuilder(
|
||||
name: String,
|
||||
buildContent: StringBuilder.() -> Unit
|
||||
): KotlinExceptionWithAttachments {
|
||||
return withAttachment(name, buildString { buildContent() })
|
||||
}
|
||||
|
||||
fun <T> KotlinExceptionWithAttachments.withAttachmentDetailed(
|
||||
name: String,
|
||||
content: T?,
|
||||
render: (T) -> String
|
||||
): KotlinExceptionWithAttachments {
|
||||
withAttachment("${name}Class", content?.let { it::class.java.name })
|
||||
withAttachment(name, content?.let(render))
|
||||
return this
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun checkWithAttachment(value: Boolean, lazyMessage: () -> String, attachments: (KotlinExceptionWithAttachments) -> Unit = {}) {
|
||||
contract { returns() implies (value) }
|
||||
@@ -68,14 +51,3 @@ inline fun checkWithAttachment(value: Boolean, lazyMessage: () -> String, attach
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
inline fun errorWithAttachment(
|
||||
message: String,
|
||||
cause: Throwable? = null,
|
||||
attachments: KotlinExceptionWithAttachments.() -> Unit = {}
|
||||
): Nothing {
|
||||
val exception = KotlinExceptionWithAttachments(message, cause)
|
||||
attachments(exception)
|
||||
throw exception
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user