Add UnsupportedPagingConfig class

This commit is contained in:
2026-06-22 10:53:33 +08:00
parent 652e05516d
commit 40168836b8
5 changed files with 39 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import java.util.Properties import java.util.*
plugins { plugins {
alias(libs.plugins.dokka) alias(libs.plugins.dokka)
@@ -8,11 +8,15 @@ plugins {
repositories { repositories {
mavenCentral() mavenCentral()
maven {
url = uri("https://gitea.neuon-kuching.com/api/packages/neuon-ai/maven")
}
} }
dependencies { dependencies {
implementation(libs.ktor.client) implementation(libs.ktor.client)
testImplementation(kotlin("test")) testImplementation(kotlin("test"))
implementation(libs.neuon.paging)
} }
tasks.test { tasks.test {

View File

@@ -0,0 +1,13 @@
package ai.neuon.utility.http.response
import io.ktor.http.*
/**
* A runtime exception that can be used to stop a request immediately
* with a specific status code.
*/
open class HttpResponseException(
val status: HttpStatusCode,
val statusMessage: String = status.description,
cause: Throwable? = null,
) : RuntimeException(cause)

View File

@@ -0,0 +1,8 @@
package ai.neuon.utility.http.response
import java.util.*
/**
* A runtime exception that indicates a specific property is not found in a [Properties]
*/
class MissingPropertyException(key: String) : RuntimeException("Missing property `${key}`")

View File

@@ -0,0 +1,10 @@
package ai.neuon.utility.http.response
import ai.neuon.utility.paging.PagingRequest
import io.ktor.http.*
class UnsupportedPagingConfig(supportedTypes: List<PagingRequest.Type>) : HttpResponseException(
status = HttpStatusCode.BadRequest,
statusMessage = supportedTypes.distinct()
.joinToString { it.key },
)

View File

@@ -2,12 +2,14 @@
dokka = "2.0.0" dokka = "2.0.0"
ktor = "3.2.0" ktor = "3.2.0"
kotlin = "2.2.0" kotlin = "2.2.0"
neuon-paging = "0.2.0"
[libraries] [libraries]
ktor-client = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" } ktor-client = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
neuon-paging = { module = "ai.neuon.utility:paging", version.ref = "neuon-paging" }
[plugins] [plugins]
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
maven-publish = { id = "maven-publish" } maven-publish = { id = "maven-publish" }