Introduce exception-specific exception classes for KotlinExceptionWithAttachments
This commit is contained in:
committed by
Space Team
parent
52c065b08a
commit
e3c31e1387
+1
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.utils.exceptions
|
||||
|
||||
import com.intellij.openapi.diagnostic.Attachment
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||
import org.jetbrains.kotlin.utils.SmartPrinter
|
||||
import org.jetbrains.kotlin.utils.withIndent
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
@@ -65,7 +64,7 @@ inline fun buildErrorWithAttachment(
|
||||
attachmentName: String = "info.txt",
|
||||
buildAttachment: ExceptionAttachmentBuilder.() -> Unit = {},
|
||||
): Nothing {
|
||||
val exception = KotlinExceptionWithAttachments(message, cause)
|
||||
val exception = KotlinIllegalArgumentExceptionWithAttachments(message, cause)
|
||||
exception.buildAttachment(attachmentName) { buildAttachment() }
|
||||
throw exception
|
||||
}
|
||||
|
||||
+33
-1
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.utils.exceptions
|
||||
|
||||
import com.intellij.openapi.diagnostic.Attachment
|
||||
import com.intellij.openapi.diagnostic.ExceptionWithAttachments
|
||||
import org.jetbrains.kotlin.utils.exceptions.KotlinExceptionWithAttachments.Companion.withAttachmentsFrom
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
interface KotlinExceptionWithAttachments : ExceptionWithAttachments {
|
||||
@@ -36,4 +37,35 @@ interface KotlinExceptionWithAttachments : ExceptionWithAttachments {
|
||||
return Attachment(newName, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinIllegalStateExceptionWithAttachments : IllegalStateException, KotlinExceptionWithAttachments {
|
||||
final override val mutableAttachments = mutableListOf<Attachment>()
|
||||
|
||||
constructor(message: String) : super(message)
|
||||
|
||||
constructor(message: String?, cause: Throwable?) : super(message, cause) {
|
||||
withAttachmentsFrom(cause)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinRuntimeExceptionWithAttachments : RuntimeException, KotlinExceptionWithAttachments {
|
||||
final override val mutableAttachments = mutableListOf<Attachment>()
|
||||
|
||||
constructor(message: String) : super(message)
|
||||
|
||||
constructor(message: String?, cause: Throwable?) : super(message, cause) {
|
||||
withAttachmentsFrom(cause)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinIllegalArgumentExceptionWithAttachments : IllegalArgumentException, KotlinExceptionWithAttachments {
|
||||
final override val mutableAttachments = mutableListOf<Attachment>()
|
||||
|
||||
constructor(message: String) : super(message)
|
||||
|
||||
constructor(message: String?, cause: Throwable?) : super(message, cause) {
|
||||
withAttachmentsFrom(cause)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user