Removed verbose errors for schema definition

This commit is contained in:
Andrew Golovashevich 2025-05-27 01:23:53 +03:00
parent 5197be80f0
commit f228bd9769
13 changed files with 34 additions and 644 deletions

View File

@ -0,0 +1,23 @@
package ru.landgrafhomyak.db.skeleton1.api.errors
import kotlinx.coroutines.CopyableThrowable
import kotlinx.coroutines.ExperimentalCoroutinesApi
import ru.landgrafhomyak.db.skeleton1.api.ReflectionApi
@OptIn(ExperimentalCoroutinesApi::class)
@ReflectionApi
public open class InternalDriverException : RuntimeException, CopyableThrowable<InternalDriverException> {
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)
override fun createCopy(): InternalDriverException? {
if (this::class !== InternalDriverException::class)
return null
return InternalDriverException(this.message, this.cause, Unit)
}
}

View File

@ -1,12 +1,22 @@
package ru.landgrafhomyak.db.skeleton1.api.errors
import kotlinx.coroutines.CopyableThrowable
import kotlinx.coroutines.ExperimentalCoroutinesApi
import ru.landgrafhomyak.db.skeleton1.api.ReflectionApi
@OptIn(ExperimentalCoroutinesApi::class)
@ReflectionApi
public abstract class SchemaDefinitionException : RuntimeException {
public open class SchemaDefinitionException : RuntimeException, CopyableThrowable<SchemaDefinitionException> {
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)
override fun createCopy(): SchemaDefinitionException? {
if (this::class !== SchemaDefinitionException::class)
return null
return SchemaDefinitionException(this.message, this.cause, Unit)
}
}

View File

@ -1,61 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.DriverMetainfo
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
@OptIn(ExperimentalCoroutinesApi::class)
public class EntityNotImplementedException : SchemaDefinitionException, CopyableThrowable<EntityNotImplementedException> {
public val provider: Any
public val driver: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>
public constructor(provider: Any, driver: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>) : super(formatMessage(provider, driver)) {
this.provider = provider
this.driver = driver
}
public constructor(provider: Any, driver: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>, customMessage: String) : super(customMessage) {
this.provider = provider
this.driver = driver
}
public constructor(provider: Any, driver: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>, customMessage: String, cause: Throwable) : super(customMessage, cause) {
this.provider = provider
this.driver = driver
}
public constructor(provider: Any, driver: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>, cause: Throwable) : super(formatMessage(provider, driver), cause) {
this.provider = provider
this.driver = driver
}
public constructor(
provider: Any, driver: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>,
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: DriverMetainfo<*, *, *, *, *, *, *, *, *, *>
): String = "$provider doesn't provides implementation for driver $driver"
}
}

View File

@ -1,60 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
@OptIn(ExperimentalCoroutinesApi::class)
public class ExportedEntitiesNotImportedException : SchemaDefinitionException, CopyableThrowable<ExportedEntitiesNotImportedException> {
public val sourceScope: Any
public val entities: Collection<Any>
public constructor(sourceScope: Any, entities: Collection<Any>) : super(formatMessage(sourceScope, entities)) {
this.sourceScope = sourceScope
this.entities = entities
}
public constructor(sourceScope: Any, entities: Collection<Any>, customMessage: String) : super(customMessage) {
this.sourceScope = sourceScope
this.entities = entities
}
public constructor(sourceScope: Any, entities: Collection<Any>, customMessage: String, cause: Throwable) : super(customMessage, cause) {
this.sourceScope = sourceScope
this.entities = entities
}
public constructor(sourceScope: Any, entities: Collection<Any>, cause: Throwable) : super(formatMessage(sourceScope, entities), cause) {
this.sourceScope = sourceScope
this.entities = entities
}
public constructor(
sourceScope: Any, entities: Collection<Any>,
message: String?, cause: Throwable?,
@Suppress("unused", "LocalVariableName") _marker: Unit
) : super(message, cause, _marker) {
this.sourceScope = sourceScope
this.entities = entities
}
override fun createCopy(): ExportedEntitiesNotImportedException? {
return ExportedEntitiesNotImportedException(
sourceScope = this.sourceScope,
entities = this.entities,
message = this.message,
cause = this.cause,
_marker = Unit
)
}
public companion object {
@JvmStatic
public fun formatMessage(
sourceScope: Any, entities: Collection<Any>,
): String = "Entities exported from $sourceScope wasn't imported to any other scope: ${entities.joinToString()}"
}
}

View File

@ -1,47 +0,0 @@
package ru.landgrafhomyak.db.skeleton1.api.errors.definition
import kotlinx.coroutines.CopyableThrowable
import kotlinx.coroutines.ExperimentalCoroutinesApi
import ru.landgrafhomyak.db.skeleton1.api.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
@OptIn(ExperimentalCoroutinesApi::class)
public class IncorrectNameException : SchemaDefinitionException, CopyableThrowable<IncorrectNameException> {
public val name: String
public constructor(name: String) : super(name) {
this.name = name
}
public constructor(name: String, customMessage: String) : super(customMessage) {
this.name = name
}
public constructor(name: String, customMessage: String, cause: Throwable) : super(customMessage, cause) {
this.name = name
}
public constructor(name: String, cause: Throwable) : super(name, cause) {
this.name = name
}
public constructor(
name: String,
message: String?,
cause: Throwable?,
@Suppress("unused", "LocalVariableName") _marker: Unit
) : super(message, cause, _marker) {
this.name = name
}
override fun createCopy(): IncorrectNameException? {
return IncorrectNameException(
name = this.name,
message = this.message,
cause = this.cause,
_marker = Unit
)
}
}

View File

@ -1,68 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
@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

@ -1,54 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
import ru.landgrafhomyak.db.skeleton1.api.module.Namespace
@ReflectionApi
@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

@ -1,54 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
import ru.landgrafhomyak.db.skeleton1.api.table.Table
@ReflectionApi
@OptIn(ExperimentalCoroutinesApi::class)
public class TableWithoutColumnsException : SchemaDefinitionException, CopyableThrowable<TableWithoutColumnsException> {
public val table: Table<*, *>
public constructor(table: Table<*, *>) : super(formatMessage(table)) {
this.table = table
}
public constructor(table: Table<*, *>, customMessage: String) : super(customMessage) {
this.table = table
}
public constructor(table: Table<*, *>, customMessage: String, cause: Throwable) : super(customMessage, cause) {
this.table = table
}
public constructor(table: Table<*, *>, cause: Throwable) : super(formatMessage(table), cause) {
this.table = table
}
public constructor(
table: Table<*, *>,
message: String?, cause: Throwable?,
@Suppress("unused", "LocalVariableName") _marker: Unit
) : super(message, cause, _marker) {
this.table = table
}
override fun createCopy(): TableWithoutColumnsException? {
return TableWithoutColumnsException(
table = this.table,
message = this.message,
cause = this.cause,
_marker = Unit
)
}
public companion object {
@JvmStatic
public fun formatMessage(
table: Table<*, *>,
): String = "Table $table doesn't have columns"
}
}

View File

@ -1,34 +0,0 @@
package ru.landgrafhomyak.db.skeleton1.api.errors.definition
import ru.landgrafhomyak.db.skeleton1.api.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
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
}
}

View File

@ -1,61 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
import ru.landgrafhomyak.db.skeleton1.api.module.Module
@ReflectionApi
@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}'"
}
}

View File

@ -1,62 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
@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

@ -1,75 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
import ru.landgrafhomyak.db.skeleton1.api.module.Module
@ReflectionApi
@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

@ -1,67 +0,0 @@
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.ReflectionApi
import ru.landgrafhomyak.db.skeleton1.api.errors.SchemaDefinitionException
@ReflectionApi
@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)"
}
}