diff --git a/build.gradle.kts b/build.gradle.kts index d3399df..2a7e6eb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,6 +41,7 @@ xomrk { sourceSets { commonMain { dependencies { + compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2") } } } diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/ConfigurationError.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/ConfigurationError.kt deleted file mode 100644 index 28db034..0000000 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/ConfigurationError.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.landgrafhomyak.db.skeleton1.api - -public open class ConfigurationError : Error { - public constructor() : super() - public constructor(message: String) : super(message) - public constructor(message: String, cause: Throwable) : super(message, cause) - public constructor(cause: Throwable) : super(cause) -} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/ExecutionException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/ExecutionException.kt deleted file mode 100644 index 5cdc277..0000000 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/ExecutionException.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.landgrafhomyak.db.skeleton1.api - -public open class ExecutionException : RuntimeException { - public constructor() : super() - public constructor(message: String) : super(message) - public constructor(message: String, cause: Throwable) : super(message, cause) - public constructor(cause: Throwable) : super(cause) -} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/InvalidRowIdError.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/InvalidRowIdError.kt deleted file mode 100644 index 2b0f0a5..0000000 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/InvalidRowIdError.kt +++ /dev/null @@ -1,6 +0,0 @@ -package ru.landgrafhomyak.db.skeleton1.api - -import kotlin.jvm.JvmField -import ru.landgrafhomyak.db.skeleton1.api.table.RowId - -public class InvalidRowIdError(@JvmField public val badRowId: RowId<*>) : Error("Referenced row was removed from table: $badRowId") \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/ExecutionException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/ExecutionException.kt new file mode 100644 index 0000000..9a859fd --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/ExecutionException.kt @@ -0,0 +1,13 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors + +import ru.landgrafhomyak.db.skeleton1.api.DebugApi + + +@DebugApi +public abstract class ExecutionException : RuntimeException { + public constructor() : super() + public constructor(message: String) : super(message) + public constructor(message: String, cause: Throwable) : super(message, cause) + public constructor(cause: Throwable) : super(cause) + public constructor(message: String?, cause: Throwable?, @Suppress("unused", "LocalVariableName") _marker: Unit) : super(message, cause) +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/SchemaDefinitionException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/SchemaDefinitionException.kt new file mode 100644 index 0000000..d7db093 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/SchemaDefinitionException.kt @@ -0,0 +1,12 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors + +import ru.landgrafhomyak.db.skeleton1.api.DebugApi + +@DebugApi +public abstract class SchemaDefinitionException : RuntimeException { + public constructor() : super() + public constructor(message: String) : super(message) + public constructor(message: String, cause: Throwable) : super(message, cause) + public constructor(cause: Throwable) : super(cause) + public constructor(message: String?, cause: Throwable?, @Suppress("unused", "LocalVariableName") _marker: Unit) : super(message, cause) +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/UninitializedParameterException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/UninitializedParameterException.kt new file mode 100644 index 0000000..bde8a69 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/UninitializedParameterException.kt @@ -0,0 +1,63 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.statement.InputParam +import ru.landgrafhomyak.db.skeleton1.api.statement._Statement + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class UninitializedParameterException : RuntimeException, CopyableThrowable { + public val statement: _Statement<*, *> + public val params: Collection> + + public constructor(statement: _Statement<*, *>, params: Collection>) : super(formatMessage(statement, params)) { + this.statement = statement + this.params = params + } + + public constructor(statement: _Statement<*, *>, params: Collection>, message: String) : super(message) { + this.statement = statement + this.params = params + } + + public constructor(statement: _Statement<*, *>, params: Collection>, message: String, cause: Throwable) : super(message, cause) { + this.statement = statement + this.params = params + } + + public constructor(statement: _Statement<*, *>, params: Collection>, cause: Throwable) : super(formatMessage(statement, params), cause) { + this.statement = statement + this.params = params + } + + public constructor( + statement: _Statement<*, *>, + params: Collection>, + message: String?, + cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause) { + this.statement = statement + this.params = params + } + + + override fun createCopy(): UninitializedParameterException? { + return UninitializedParameterException( + statement = this.statement, + params = this.params, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage(statement: _Statement<*, *>, params: Collection>): String = + "While preparing statement $statement following parameters wasn't initialized: ${params.joinToString()}" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/EntityNotImplementedException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/EntityNotImplementedException.kt new file mode 100644 index 0000000..40a1967 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/EntityNotImplementedException.kt @@ -0,0 +1,61 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.DriverType +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class EntityNotImplementedException : SchemaDefinitionException, CopyableThrowable { + public val provider: Any + public val driver: DriverType<*, *, *, *, *, *, *, *, *> + + public constructor(provider: Any, driver: DriverType<*, *, *, *, *, *, *, *, *>) : super(formatMessage(provider, driver)) { + this.provider = provider + this.driver = driver + } + + public constructor(provider: Any, driver: DriverType<*, *, *, *, *, *, *, *, *>, customMessage: String) : super(customMessage) { + this.provider = provider + this.driver = driver + } + + public constructor(provider: Any, driver: DriverType<*, *, *, *, *, *, *, *, *>, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.provider = provider + this.driver = driver + } + + public constructor(provider: Any, driver: DriverType<*, *, *, *, *, *, *, *, *>, cause: Throwable) : super(formatMessage(provider, driver), cause) { + this.provider = provider + this.driver = driver + } + + public constructor( + provider: Any, driver: DriverType<*, *, *, *, *, *, *, *, *>, + message: String?, cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.provider = provider + this.driver = driver + } + + override fun createCopy(): EntityNotImplementedException? { + return EntityNotImplementedException( + provider = this.provider, + driver = this.driver, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage( + provider: Any, driver: DriverType<*, *, *, *, *, *, *, *, *> + ): String = "$provider doesn't provides implementation for driver $driver" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/IncorrectNameException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/IncorrectNameException.kt new file mode 100644 index 0000000..cdc3d3a --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/IncorrectNameException.kt @@ -0,0 +1,64 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException +import ru.landgrafhomyak.db.skeleton1.api.statement.InputParam +import ru.landgrafhomyak.db.skeleton1.api.statement._Statement + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class IncorrectNameException : SchemaDefinitionException, CopyableThrowable { + public val statement: _Statement<*, *> + public val params: Collection> + + public constructor(statement: _Statement<*, *>, params: Collection>) : super(formatMessage(statement, params)) { + this.statement = statement + this.params = params + } + + public constructor(statement: _Statement<*, *>, params: Collection>, message: String) : super(message) { + this.statement = statement + this.params = params + } + + public constructor(statement: _Statement<*, *>, params: Collection>, message: String, cause: Throwable) : super(message, cause) { + this.statement = statement + this.params = params + } + + public constructor(statement: _Statement<*, *>, params: Collection>, cause: Throwable) : super(formatMessage(statement, params), cause) { + this.statement = statement + this.params = params + } + + public constructor( + statement: _Statement<*, *>, + params: Collection>, + message: String?, + cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.statement = statement + this.params = params + } + + + override fun createCopy(): IncorrectNameException? { + return IncorrectNameException( + statement = this.statement, + params = this.params, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage(statement: _Statement<*, *>, params: Collection>): String = + "While preparing statement $statement following parameters wasn't initialized: ${params.joinToString()}" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/NameConflictException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/NameConflictException.kt new file mode 100644 index 0000000..96010bc --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/NameConflictException.kt @@ -0,0 +1,68 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class NameConflictException : SchemaDefinitionException, CopyableThrowable { + public val scope: Any + public val nameOwner: Any + public val name: String + + public constructor(scope: Any, nameOwner: Any, name: String) : super(formatMessage(scope, nameOwner, name)) { + this.scope = scope + this.nameOwner = nameOwner + this.name = name + } + + public constructor(scope: Any, nameOwner: Any, name: String, customMessage: String) : super(customMessage) { + this.scope = scope + this.nameOwner = nameOwner + this.name = name + } + + public constructor(scope: Any, nameOwner: Any, name: String, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.scope = scope + this.nameOwner = nameOwner + this.name = name + } + + + public constructor(scope: Any, nameOwner: Any, name: String, cause: Throwable) : super(formatMessage(scope, nameOwner, name), cause) { + this.scope = scope + this.nameOwner = nameOwner + this.name = name + } + + public constructor( + scope: Any, nameOwner: Any, name: String, + message: String?, cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.scope = scope + this.nameOwner = nameOwner + this.name = name + } + + override fun createCopy(): NameConflictException? { + return NameConflictException( + scope = this.scope, + nameOwner = this.nameOwner, + name = this.name, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage( + scope: Any, nameOwner: Any, name: String, + ): String = "Name '${name}' already taken by $nameOwner inside $scope" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/NamespaceAlreadyBusyException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/NamespaceAlreadyBusyException.kt new file mode 100644 index 0000000..499a930 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/NamespaceAlreadyBusyException.kt @@ -0,0 +1,54 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException +import ru.landgrafhomyak.db.skeleton1.api.module.Namespace + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class NamespaceAlreadyBusyException : SchemaDefinitionException, CopyableThrowable { + public val namespace: Namespace<*, *> + + public constructor(namespace: Namespace<*, *>) : super(formatMessage(namespace)) { + this.namespace = namespace + } + + public constructor(namespace: Namespace<*, *>, customMessage: String) : super(customMessage) { + this.namespace = namespace + } + + public constructor(namespace: Namespace<*, *>, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.namespace = namespace + } + + public constructor(namespace: Namespace<*, *>, cause: Throwable) : super(formatMessage(namespace), cause) { + this.namespace = namespace + } + + public constructor( + namespace: Namespace<*, *>, + message: String?, cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.namespace = namespace + } + + override fun createCopy(): NamespaceAlreadyBusyException? { + return NamespaceAlreadyBusyException( + namespace = this.namespace, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage( + namespace: Namespace<*, *> + ): String = "Namespace ${namespace.name} is busy: attempt to allocate something in namespace captured by module or attempt to substitute module to non-empty namespace" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/UnreferencedEntityAtUpgradeException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/UnreferencedEntityAtUpgradeException.kt new file mode 100644 index 0000000..190d987 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/UnreferencedEntityAtUpgradeException.kt @@ -0,0 +1,62 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class UnreferencedEntityAtUpgradeException : SchemaDefinitionException, CopyableThrowable { + public val oldScope: Any + public val unprocessedEntities: Collection + + public constructor(oldScope: Any, unprocessedEntities: Collection) : super(formatMessage(oldScope, unprocessedEntities)) { + this.oldScope = oldScope + this.unprocessedEntities = unprocessedEntities + } + + public constructor(oldScope: Any, unprocessedEntities: Collection, customMessage: String) : super(customMessage) { + this.oldScope = oldScope + this.unprocessedEntities = unprocessedEntities + } + + public constructor(oldScope: Any, unprocessedEntities: Collection, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.oldScope = oldScope + this.unprocessedEntities = unprocessedEntities + } + + + public constructor(oldScope: Any, unprocessedEntities: Collection, cause: Throwable) : super(formatMessage(oldScope, unprocessedEntities), cause) { + this.oldScope = oldScope + this.unprocessedEntities = unprocessedEntities + } + + public constructor( + oldScope: Any, unprocessedEntities: Collection, + message: String?, cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.oldScope = oldScope + this.unprocessedEntities = unprocessedEntities + } + + override fun createCopy(): UnreferencedEntityAtUpgradeException? { + return UnreferencedEntityAtUpgradeException( + oldScope = this.oldScope, + unprocessedEntities = this.unprocessedEntities, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage( + scope: Any, + entities: Collection, + ): String = "While upgrading $scope following entities wasn't referenced: ${entities.joinToString()}" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/VersionDuplicationException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/VersionDuplicationException.kt new file mode 100644 index 0000000..4893ebf --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/VersionDuplicationException.kt @@ -0,0 +1,75 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException +import ru.landgrafhomyak.db.skeleton1.api.module.Module + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class VersionDuplicationException : SchemaDefinitionException, CopyableThrowable { + public val template: Module.Template<*> + public val versionOwner: Module<*, *> + public val newModule: Module<*, *> + public val version: String + + public constructor(template: Module.Template<*>, versionOwner: Module<*, *>, newModule: Module<*, *>, version: String) : super(formatMessage(template, versionOwner, newModule, version)) { + this.template = template + this.versionOwner = versionOwner + this.newModule = newModule + this.version = version + } + + public constructor(template: Module.Template<*>, versionOwner: Module<*, *>, newModule: Module<*, *>, version: String, customMessage: String) : super(customMessage) { + this.template = template + this.versionOwner = versionOwner + this.newModule = newModule + this.version = version + } + + public constructor(template: Module.Template<*>, versionOwner: Module<*, *>, newModule: Module<*, *>, version: String, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.template = template + this.versionOwner = versionOwner + this.newModule = newModule + this.version = version + } + + public constructor(template: Module.Template<*>, versionOwner: Module<*, *>, newModule: Module<*, *>, version: String, cause: Throwable) : super(formatMessage(template, versionOwner, newModule, version), cause) { + this.template = template + this.versionOwner = versionOwner + this.newModule = newModule + this.version = version + } + + public constructor( + template: Module.Template<*>, versionOwner: Module<*, *>, newModule: Module<*, *>, version: String, + message: String?, cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.template = template + this.versionOwner = versionOwner + this.newModule = newModule + this.version = version + } + + override fun createCopy(): VersionDuplicationException? { + return VersionDuplicationException( + template = this.template, + versionOwner = this.versionOwner, + newModule = this.newModule, + version = this.version, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage( + template: Module.Template<*>, versionOwner: Module<*, *>, newModule: Module<*, *>, version: String + ): String = "Version '${version}' already associated with $versionOwner and $newModule provided by $template has the same version (circular upgrades are prohibited)" + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/WrongScopeException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/WrongScopeException.kt new file mode 100644 index 0000000..a029b79 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/WrongScopeException.kt @@ -0,0 +1,68 @@ +package ru.landgrafhomyak.db.skeleton1.api.errors.definition + +import kotlin.jvm.JvmStatic +import kotlinx.coroutines.CopyableThrowable +import kotlinx.coroutines.ExperimentalCoroutinesApi +import ru.landgrafhomyak.db.skeleton1.api.DebugApi +import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException +import ru.landgrafhomyak.db.skeleton1.api.module.Module + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class WrongScopeException : SchemaDefinitionException, CopyableThrowable { + public val wrongObject: Any + public val currentScope: Any + public val correctScope: Any + + public constructor(wrongObject: Any, currentScope: Any, correctScope: Any) : super(formatMessage(wrongObject, currentScope, correctScope)) { + this.wrongObject = wrongObject + this.currentScope = currentScope + this.correctScope = correctScope + } + + public constructor(wrongObject: Any, currentScope: Any, correctScope: Any, customMessage: String) : super(customMessage) { + this.wrongObject = wrongObject + this.currentScope = currentScope + this.correctScope = correctScope + } + + public constructor(wrongObject: Any, currentScope: Any, correctScope: Any, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.wrongObject = wrongObject + this.currentScope = currentScope + this.correctScope = correctScope + } + + public constructor(wrongObject: Any, currentScope: Any, correctScope: Any, cause: Throwable) : super(formatMessage(wrongObject, currentScope, correctScope), cause) { + this.wrongObject = wrongObject + this.currentScope = currentScope + this.correctScope = correctScope + } + + public constructor( + wrongObject: Any, currentScope: Any, correctScope: Any, + message: String?, cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause, _marker) { + this.wrongObject = wrongObject + this.currentScope = currentScope + this.correctScope = correctScope + } + + override fun createCopy(): WrongScopeException? { + return WrongScopeException( + wrongObject = this.wrongObject, + currentScope = this.currentScope, + correctScope = this.correctScope, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } + + public companion object { + @JvmStatic + public fun formatMessage( + wrongObject: Any, currentScope: Any, correctScope: Any + ): String = "Entity $wrongObject passed to wrong scope $currentScope (must be $correctScope)" + } +} \ No newline at end of file