Errors for schema synchronization and some additional errors for schema definition
This commit is contained in:
parent
60d57c3656
commit
ba11a41dc9
@ -0,0 +1,12 @@
|
|||||||
|
package ru.landgrafhomyak.db.skeleton1.api.errors
|
||||||
|
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.DebugApi
|
||||||
|
|
||||||
|
@DebugApi
|
||||||
|
public abstract class SchemaSynchronizationException : 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)
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
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.DriverMetainfo
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
|
||||||
|
|
||||||
|
@DebugApi
|
||||||
|
public abstract class UnboundParameterException : SchemaDefinitionException {
|
||||||
|
public val constructor: Any
|
||||||
|
|
||||||
|
public constructor(constructor: Any) : super() {
|
||||||
|
this.constructor = constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(constructor: Any, customMessage: String) : super(customMessage) {
|
||||||
|
this.constructor = constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(constructor: Any, customMessage: String, cause: Throwable) : super(customMessage, cause) {
|
||||||
|
this.constructor = constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(constructor: Any, cause: Throwable) : super(cause) {
|
||||||
|
this.constructor = constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
constructor: Any,
|
||||||
|
message: String?, cause: Throwable?,
|
||||||
|
@Suppress("unused", "LocalVariableName") _marker: Unit
|
||||||
|
) : super(message, cause, _marker) {
|
||||||
|
this.constructor = constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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.errors.SchemaDefinitionException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.module.Module
|
||||||
|
|
||||||
|
@DebugApi
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
|
public class UnknownVersionException : SchemaDefinitionException, CopyableThrowable<UnknownVersionException> {
|
||||||
|
public val template: Module.Template<*>
|
||||||
|
public val version: String
|
||||||
|
|
||||||
|
public constructor(template: Module.Template<*>, version: String) : super(formatMessage(template, version)) {
|
||||||
|
this.template = template
|
||||||
|
this.version = version
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(template: Module.Template<*>, version: String, customMessage: String) : super(customMessage) {
|
||||||
|
this.template = template
|
||||||
|
this.version = version
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(template: Module.Template<*>, version: String, customMessage: String, cause: Throwable) : super(customMessage, cause) {
|
||||||
|
this.template = template
|
||||||
|
this.version = version
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(template: Module.Template<*>, version: String, cause: Throwable) : super(formatMessage(template, version), cause) {
|
||||||
|
this.template = template
|
||||||
|
this.version = version
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
template: Module.Template<*>, version: String,
|
||||||
|
message: String?, cause: Throwable?,
|
||||||
|
@Suppress("unused", "LocalVariableName") _marker: Unit
|
||||||
|
) : super(message, cause, _marker) {
|
||||||
|
this.template = template
|
||||||
|
this.version = version
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createCopy(): UnknownVersionException? {
|
||||||
|
return UnknownVersionException(
|
||||||
|
template = this.template,
|
||||||
|
version = this.version,
|
||||||
|
message = this.message,
|
||||||
|
cause = this.cause,
|
||||||
|
_marker = Unit
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
@JvmStatic
|
||||||
|
public fun formatMessage(
|
||||||
|
template: Module.Template<*>, version: String
|
||||||
|
): String = "Template $template doesn't knows version '${version}'"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package ru.landgrafhomyak.db.skeleton1.api.errors.synchronization
|
||||||
|
|
||||||
|
import kotlin.RuntimeException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.DebugApi
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaSynchronizationException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.module.Module
|
||||||
|
|
||||||
|
@DebugApi
|
||||||
|
public abstract class SchemaExecutionException : SchemaSynchronizationException {
|
||||||
|
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, _marker)
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package ru.landgrafhomyak.db.skeleton1.api.errors.synchronization
|
||||||
|
|
||||||
|
import kotlin.RuntimeException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.DebugApi
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaSynchronizationException
|
||||||
|
import ru.landgrafhomyak.db.skeleton1.api.module.Module
|
||||||
|
|
||||||
|
@DebugApi
|
||||||
|
public abstract class SchemaMismatchException : SchemaSynchronizationException {
|
||||||
|
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, _marker)
|
||||||
|
}
|
@ -22,31 +22,31 @@ public interface Module<mUE : Any, IK : Any> {
|
|||||||
@get:JvmName("getParent")
|
@get:JvmName("getParent")
|
||||||
public val parent: Module<*, IK>?
|
public val parent: Module<*, IK>?
|
||||||
|
|
||||||
public interface Constructor<mUE : Any, RUNTIME_KEY : Any> {
|
public interface Constructor<mUE : Any, IK : Any> {
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
@get:JvmName("versionKey")
|
@get:JvmName("versionKey")
|
||||||
public val versionKey: String
|
public val versionKey: String
|
||||||
|
|
||||||
public fun createSchema(context: ModuleConstructorScope<mUE, RUNTIME_KEY>): mUE
|
public fun createSchema(context: ModuleConstructorScope<mUE, IK>): mUE
|
||||||
|
|
||||||
public suspend fun initData(ext: mUE, compiler: QueriesCompiler<RUNTIME_KEY>, transaction: Transaction<RUNTIME_KEY>) {}
|
public suspend fun initData(ext: mUE, compiler: QueriesCompiler<IK>, transaction: Transaction<IK>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Upgrade<nmUE : Any, omUE : Any, RUNTIME_KEY : Any> {
|
public interface Upgrade<nmUE : Any, omUE : Any, IK : Any> {
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
@get:JvmName("versionKey")
|
@get:JvmName("versionKey")
|
||||||
public val versionKey: String
|
public val versionKey: String
|
||||||
|
|
||||||
public fun upgradeSchema(context: ModuleUpgradeScope<nmUE, omUE, RUNTIME_KEY>): nmUE
|
public fun upgradeSchema(context: ModuleUpgradeScope<nmUE, omUE, IK>): nmUE
|
||||||
|
|
||||||
public suspend fun upgradeData(ext: nmUE, compiler: QueriesCompiler<RUNTIME_KEY>, transaction: Transaction<RUNTIME_KEY>) {}
|
public suspend fun upgradeData(ext: nmUE, compiler: QueriesCompiler<IK>, transaction: Transaction<IK>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Template<@Suppress("unused") mUE : Any> {
|
public interface Template<@Suppress("unused") mUE : Any> {
|
||||||
@LowLevelApi
|
@LowLevelApi
|
||||||
public fun <RUNTIME_KEY : Any> getConstructor(): Constructor<*, RUNTIME_KEY>
|
public fun <IK : Any> getConstructor(): Constructor<*, IK>
|
||||||
|
|
||||||
@LowLevelApi
|
@LowLevelApi
|
||||||
public fun <RUNTIME_KEY : Any> getUpgrade(version: String): Upgrade<*, *, RUNTIME_KEY>?
|
public fun <IK : Any> getUpgrade(version: String): Upgrade<*, *, IK>?
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user