diff --git a/rd-kt/rd-core/src/commonMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt b/rd-kt/rd-core/src/commonMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt index a57dc408a..0f112f2cd 100644 --- a/rd-kt/rd-core/src/commonMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt +++ b/rd-kt/rd-core/src/commonMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt @@ -1,12 +1,21 @@ package com.jetbrains.rd.util.reactive import com.jetbrains.rd.util.ExecutionException -import com.jetbrains.rd.util.getThrowableText +expect class RdFault constructor( + reasonTypeFqn: String, + reasonMessage: String, + localizedReasonMessage: String, + reasonAsText: String, + reason: Throwable? = null +) : ExecutionException { + val reasonTypeFqn: String + val reasonMessage: String + val localizedReasonMessage: String + val reasonAsText: String -class RdFault constructor(val reasonTypeFqn: String, val reasonMessage: String, val reasonAsText: String, reason: Throwable? = null) - : ExecutionException(reasonMessage + if (reason == null) ", reason: $reasonAsText" else "", reason) { + constructor(reason: Throwable) - constructor (reason: Throwable) : this (reason::class.simpleName?:"", reason.message ?: "-- no message --", reason.getThrowableText(), reason) { - } -} \ No newline at end of file + @Deprecated("Use the override with localizedReasonMessage") + constructor(reasonTypeFqn: String, reasonMessage: String, reasonAsText: String, reason: Throwable? = null) +} diff --git a/rd-kt/rd-core/src/jsMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt b/rd-kt/rd-core/src/jsMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt new file mode 100644 index 000000000..ac8d1b068 --- /dev/null +++ b/rd-kt/rd-core/src/jsMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt @@ -0,0 +1,30 @@ +package com.jetbrains.rd.util.reactive + +import com.jetbrains.rd.util.ExecutionException +import com.jetbrains.rd.util.getThrowableText + +actual class RdFault actual constructor( + actual val reasonTypeFqn: String, + actual val reasonMessage: String, + actual val localizedReasonMessage: String, + actual val reasonAsText: String, + reason: Throwable? +) : ExecutionException(reasonMessage + if (reason == null) ", reason: $reasonAsText" else "", reason) { + + actual constructor (reason: Throwable) : this( + reason::class.simpleName ?: "", + reason.message ?: "-- no message --", + reason.message ?: "-- no message --", + reason.getThrowableText(), + reason + ) + + @Deprecated("Use the override with localizedReasonMessage") + actual constructor(reasonTypeFqn: String, reasonMessage: String, reasonAsText: String, reason: Throwable?) : this( + reasonTypeFqn, + reasonMessage, + reasonMessage, + reasonAsText, + reason + ) +} diff --git a/rd-kt/rd-core/src/jvmMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt b/rd-kt/rd-core/src/jvmMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt new file mode 100644 index 000000000..696e4fb3d --- /dev/null +++ b/rd-kt/rd-core/src/jvmMain/kotlin/com/jetbrains/rd/util/reactive/RdFault.kt @@ -0,0 +1,31 @@ +package com.jetbrains.rd.util.reactive + +import com.jetbrains.rd.util.ExecutionException +import com.jetbrains.rd.util.getThrowableText +import org.jetbrains.annotations.Nls + +actual class RdFault actual constructor( + actual val reasonTypeFqn: String, + actual val reasonMessage: String, + @field:Nls @get:Nls @Nls actual val localizedReasonMessage: String, + actual val reasonAsText: String, + reason: Throwable? +) : ExecutionException(reasonMessage + if (reason == null) ", reason: $reasonAsText" else "", reason) { + + actual constructor(reason: Throwable) : this( + reason::class.simpleName ?: "", + reason.message ?: "-- no message --", + reason.localizedMessage ?: reason.message ?: "-- no message --", + reason.getThrowableText(), + reason + ) + + @Deprecated("Use the override with localizedReasonMessage") + actual constructor(reasonTypeFqn: String, reasonMessage: String, reasonAsText: String, reason: Throwable?) : this( + reasonTypeFqn, + reasonMessage, + reasonMessage, + reasonAsText, + reason + ) +} diff --git a/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/example/ExampleModel.kt b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/example/ExampleModel.kt index c47cde972..372cdb740 100644 --- a/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/example/ExampleModel.kt +++ b/rd-kt/rd-gen/src/test/kotlin/com/jetbrains/rd/generator/test/cases/generator/example/ExampleModel.kt @@ -136,6 +136,7 @@ class TestExample { classloader.scanForResourcesContaining("com.jetbrains.rd.util") + classloader.scanForResourcesContaining("org.jetbrains.annotations") + rdgen.verbose *= true rdgen.classpath *= rdFrameworkClasspath.joinToString(File.pathSeparator) val generatedSources = File(kotlinGeneratedSourcesDir).walk().toList()