From b5094362aa3b68734ff5581e936c78e989826e54 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 30 May 2024 11:23:32 +0800 Subject: [PATCH] Add UnknownServiceException Port Java's UnknownServiceException for all platforms. --- core/common/src/-CommonPlatform.kt | 5 +++++ core/js/src/-PlatformJs.kt | 6 ++++++ core/jvm/src/-JvmPlatform.kt | 2 ++ core/native/src/-NonJvmPlatform.kt | 6 ++++++ core/wasm/src/-PlatformWasm.kt | 6 ++++++ 5 files changed, 25 insertions(+) diff --git a/core/common/src/-CommonPlatform.kt b/core/common/src/-CommonPlatform.kt index 99824284c..7235eb165 100644 --- a/core/common/src/-CommonPlatform.kt +++ b/core/common/src/-CommonPlatform.kt @@ -39,6 +39,11 @@ public expect open class EOFException : IOException { public constructor(message: String?) } +public expect open class UnknownServiceException : IOException { + public constructor() + public constructor(message: String?) +} + // There is no actual AutoCloseable on JVM (https://youtrack.jetbrains.com/issue/KT-55777), // but on JVM we have to explicitly implement by RawSink and the compiler does not allow that. diff --git a/core/js/src/-PlatformJs.kt b/core/js/src/-PlatformJs.kt index 51eb04768..326fa8199 100644 --- a/core/js/src/-PlatformJs.kt +++ b/core/js/src/-PlatformJs.kt @@ -21,6 +21,12 @@ public actual open class EOFException : IOException { public actual constructor(message: String?) : super(message) } +public actual open class UnknownServiceException : IOException { + public actual constructor() : super() + + public actual constructor(message: String?) : super(message) +} + internal actual fun withCaughtException(block: () -> Unit): Throwable? { try { block() diff --git a/core/jvm/src/-JvmPlatform.kt b/core/jvm/src/-JvmPlatform.kt index 92e17424a..a3475af88 100644 --- a/core/jvm/src/-JvmPlatform.kt +++ b/core/jvm/src/-JvmPlatform.kt @@ -24,3 +24,5 @@ package kotlinx.io public actual typealias IOException = java.io.IOException public actual typealias EOFException = java.io.EOFException + +public actual typealias UnknownServiceException = java.net.UnknownServiceException diff --git a/core/native/src/-NonJvmPlatform.kt b/core/native/src/-NonJvmPlatform.kt index 8a06214ff..29e8e8f1a 100644 --- a/core/native/src/-NonJvmPlatform.kt +++ b/core/native/src/-NonJvmPlatform.kt @@ -35,3 +35,9 @@ public actual open class EOFException : IOException { public actual constructor(message: String?) : super(message) } + +public actual open class UnknownServiceException : IOException { + public actual constructor() : super() + + public actual constructor(message: String?) : super(message) +} diff --git a/core/wasm/src/-PlatformWasm.kt b/core/wasm/src/-PlatformWasm.kt index 031d5513b..b442c4cb9 100644 --- a/core/wasm/src/-PlatformWasm.kt +++ b/core/wasm/src/-PlatformWasm.kt @@ -20,3 +20,9 @@ public actual open class EOFException : IOException { public actual constructor(message: String?) : super(message) } + +public actual open class UnknownServiceException : IOException { + public actual constructor() : super() + + public actual constructor(message: String?) : super(message) +}