Wizard: make YamlParsingError to be exception error
This commit is contained in:
+2
-6
@@ -1,10 +1,6 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.core
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Error
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.asString
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ExceptionError
|
||||
import org.yaml.snakeyaml.parser.ParserException
|
||||
|
||||
data class YamlParsingError(val exception: ParserException) : Error() {
|
||||
override val message: String
|
||||
get() = exception.asString()
|
||||
}
|
||||
data class YamlParsingError(override val exception: ParserException) : ExceptionError()
|
||||
+8
-9
@@ -9,7 +9,14 @@ abstract class Error {
|
||||
abstract class ExceptionError : Error() {
|
||||
abstract val exception: Exception
|
||||
override val message: String
|
||||
get() = exception.asString()
|
||||
get() = exception::class.simpleName!!.removeSuffix("Exception").splitByWords() +
|
||||
exception.message?.let { ": $it" }.orEmpty()
|
||||
|
||||
companion object {
|
||||
private val wordRegex = "[A-Z][a-z0-9]+".toRegex()
|
||||
private fun String.splitByWords() =
|
||||
wordRegex.findAll(this).joinToString(separator = " ") { it.value }
|
||||
}
|
||||
}
|
||||
|
||||
data class IOError(override val exception: IOException) : ExceptionError()
|
||||
@@ -79,11 +86,3 @@ data class ModuleNotFoundError(val path: String) : Error() {
|
||||
}
|
||||
|
||||
|
||||
fun Throwable.asString() =
|
||||
this::class.simpleName!!.removeSuffix("Exception").splitByWords() + message?.let { ": $it" }.orEmpty()
|
||||
|
||||
private val wordRegex = "[A-Z][a-z0-9]+".toRegex()
|
||||
private fun String.splitByWords() =
|
||||
wordRegex.findAll(this).joinToString(separator = " ") { it.value }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user