From 3633ed898dc2235215cc426c08e96afba9986f5d Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Fri, 16 May 2025 15:57:55 +0300 Subject: [PATCH] Some missed errors --- .../AccessWhileInitializationException.kt | 56 +++++++++++++++++ .../ExportedEntitiesNotImportedException.kt | 60 +++++++++++++++++++ .../definition/IncorrectNameException.kt | 38 ++++-------- .../TableWithoutColumnsException.kt | 54 +++++++++++++++++ 4 files changed, 182 insertions(+), 26 deletions(-) create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/AccessWhileInitializationException.kt create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/ExportedEntitiesNotImportedException.kt create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/TableWithoutColumnsException.kt diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/AccessWhileInitializationException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/AccessWhileInitializationException.kt new file mode 100644 index 0000000..d5e4898 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/AccessWhileInitializationException.kt @@ -0,0 +1,56 @@ +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 AccessWhileInitializationException : IllegalStateException, CopyableThrowable { + public val `object`: Any + public val member: Any + + public constructor(`object`: Any, member: Any) : super() { + this.`object` = `object` + this.member = member + } + + public constructor(`object`: Any, member: Any, message: String) : super(message) { + this.`object` = `object` + this.member = member + } + + public constructor(`object`: Any, member: Any, message: String, cause: Throwable) : super(message, cause) { + this.`object` = `object` + this.member = member + } + + public constructor(`object`: Any, member: Any, cause: Throwable) : super(cause) { + this.`object` = `object` + this.member = member + } + + public constructor( + `object`: Any, member: Any, + message: String?, + cause: Throwable?, + @Suppress("unused", "LocalVariableName") _marker: Unit + ) : super(message, cause) { + this.`object` = `object` + this.member = member + } + + + override fun createCopy(): AccessWhileInitializationException? { + return AccessWhileInitializationException( + `object` = this.`object`, + member = this.member, + message = this.message, + cause = this.cause, + _marker = Unit + ) + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/ExportedEntitiesNotImportedException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/ExportedEntitiesNotImportedException.kt new file mode 100644 index 0000000..5e26105 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/ExportedEntitiesNotImportedException.kt @@ -0,0 +1,60 @@ +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 ExportedEntitiesNotImportedException : SchemaDefinitionException, CopyableThrowable { + public val sourceScope: Any + public val entities: Collection + + public constructor(sourceScope: Any, entities: Collection) : super(formatMessage(sourceScope, entities)) { + this.sourceScope = sourceScope + this.entities = entities + } + + public constructor(sourceScope: Any, entities: Collection, customMessage: String) : super(customMessage) { + this.sourceScope = sourceScope + this.entities = entities + } + + public constructor(sourceScope: Any, entities: Collection, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.sourceScope = sourceScope + this.entities = entities + } + + public constructor(sourceScope: Any, entities: Collection, cause: Throwable) : super(formatMessage(sourceScope, entities), cause) { + this.sourceScope = sourceScope + this.entities = entities + } + + public constructor( + sourceScope: Any, entities: Collection, + 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, + ): String = "Entities exported from $sourceScope wasn't imported to any other scope: ${entities.joinToString()}" + } +} \ 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 index cdc3d3a..742a5be 100644 --- 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 @@ -11,54 +11,40 @@ 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 val name: String - public constructor(statement: _Statement<*, *>, params: Collection>) : super(formatMessage(statement, params)) { - this.statement = statement - this.params = params + public constructor(name: String) : super(name) { + this.name = name } - public constructor(statement: _Statement<*, *>, params: Collection>, message: String) : super(message) { - this.statement = statement - this.params = params + public constructor(name: String, customMessage: String) : super(customMessage) { + this.name = name } - public constructor(statement: _Statement<*, *>, params: Collection>, message: String, cause: Throwable) : super(message, cause) { - this.statement = statement - this.params = params + public constructor(name: String, customMessage: String, cause: Throwable) : super(customMessage, cause) { + this.name = name } - public constructor(statement: _Statement<*, *>, params: Collection>, cause: Throwable) : super(formatMessage(statement, params), cause) { - this.statement = statement - this.params = params + public constructor(name: String, cause: Throwable) : super(name, cause) { + this.name = name } public constructor( - statement: _Statement<*, *>, - params: Collection>, + name: String, message: String?, cause: Throwable?, @Suppress("unused", "LocalVariableName") _marker: Unit ) : super(message, cause, _marker) { - this.statement = statement - this.params = params + this.name = name } override fun createCopy(): IncorrectNameException? { return IncorrectNameException( - statement = this.statement, - params = this.params, + name = this.name, 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/TableWithoutColumnsException.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/TableWithoutColumnsException.kt new file mode 100644 index 0000000..f35604c --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/errors/definition/TableWithoutColumnsException.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.table.Table + +@DebugApi +@OptIn(ExperimentalCoroutinesApi::class) +public class TableWithoutColumnsException : SchemaDefinitionException, CopyableThrowable { + 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" + } +} \ No newline at end of file