This commit is contained in:
Andrew Golovashevich 2025-05-11 14:47:11 +03:00
parent 4d76d9bf6c
commit 6de9eba7b0
14 changed files with 541 additions and 22 deletions

View File

@ -41,6 +41,7 @@ xomrk {
sourceSets {
commonMain {
dependencies {
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
}
}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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")

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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<UninitializedParameterException> {
public val statement: _Statement<*, *>
public val params: Collection<InputParam<*, *, *>>
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>) : super(formatMessage(statement, params)) {
this.statement = statement
this.params = params
}
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>, message: String) : super(message) {
this.statement = statement
this.params = params
}
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>, message: String, cause: Throwable) : super(message, cause) {
this.statement = statement
this.params = params
}
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>, cause: Throwable) : super(formatMessage(statement, params), cause) {
this.statement = statement
this.params = params
}
public constructor(
statement: _Statement<*, *>,
params: Collection<InputParam<*, *, *>>,
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<InputParam<*, *, *>>): String =
"While preparing statement $statement following parameters wasn't initialized: ${params.joinToString()}"
}
}

View File

@ -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<EntityNotImplementedException> {
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"
}
}

View File

@ -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<IncorrectNameException> {
public val statement: _Statement<*, *>
public val params: Collection<InputParam<*, *, *>>
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>) : super(formatMessage(statement, params)) {
this.statement = statement
this.params = params
}
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>, message: String) : super(message) {
this.statement = statement
this.params = params
}
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>, message: String, cause: Throwable) : super(message, cause) {
this.statement = statement
this.params = params
}
public constructor(statement: _Statement<*, *>, params: Collection<InputParam<*, *, *>>, cause: Throwable) : super(formatMessage(statement, params), cause) {
this.statement = statement
this.params = params
}
public constructor(
statement: _Statement<*, *>,
params: Collection<InputParam<*, *, *>>,
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<InputParam<*, *, *>>): String =
"While preparing statement $statement following parameters wasn't initialized: ${params.joinToString()}"
}
}

View File

@ -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<NameConflictException> {
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"
}
}

View File

@ -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<NamespaceAlreadyBusyException> {
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"
}
}

View File

@ -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<UnreferencedEntityAtUpgradeException> {
public val oldScope: Any
public val unprocessedEntities: Collection<Any>
public constructor(oldScope: Any, unprocessedEntities: Collection<Any>) : super(formatMessage(oldScope, unprocessedEntities)) {
this.oldScope = oldScope
this.unprocessedEntities = unprocessedEntities
}
public constructor(oldScope: Any, unprocessedEntities: Collection<Any>, customMessage: String) : super(customMessage) {
this.oldScope = oldScope
this.unprocessedEntities = unprocessedEntities
}
public constructor(oldScope: Any, unprocessedEntities: Collection<Any>, customMessage: String, cause: Throwable) : super(customMessage, cause) {
this.oldScope = oldScope
this.unprocessedEntities = unprocessedEntities
}
public constructor(oldScope: Any, unprocessedEntities: Collection<Any>, cause: Throwable) : super(formatMessage(oldScope, unprocessedEntities), cause) {
this.oldScope = oldScope
this.unprocessedEntities = unprocessedEntities
}
public constructor(
oldScope: Any, unprocessedEntities: Collection<Any>,
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<Any>,
): String = "While upgrading $scope following entities wasn't referenced: ${entities.joinToString()}"
}
}

View File

@ -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<VersionDuplicationException> {
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)"
}
}

View File

@ -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<WrongScopeException> {
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)"
}
}