Multiplatform Exceptions to deal with kotlin bug

This commit is contained in:
Him188 2020-02-15 12:12:30 +08:00
parent 5eb731e975
commit f989cd9391
4 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package net.mamoe.mirai.contact
/**
* 权限不足
*/
actual class PermissionDeniedException : IllegalStateException {
actual constructor() : super("Permission denied")
actual constructor(message: String?) : super(message)
}

View File

@ -0,0 +1,9 @@
package net.mamoe.mirai.event.events
@Suppress("unused")
actual class EventCancelledException : RuntimeException {
actual constructor() : super()
actual constructor(message: String?) : super(message)
actual constructor(message: String?, cause: Throwable?) : super(message, cause)
actual constructor(cause: Throwable?) : super(cause)
}

View File

@ -0,0 +1,9 @@
package net.mamoe.mirai.contact
/**
* 权限不足
*/ // 不要删除多平台结构
actual class PermissionDeniedException : IllegalStateException {
actual constructor() : super("Permission denied")
actual constructor(message: String?) : super(message)
}

View File

@ -0,0 +1,12 @@
package net.mamoe.mirai.event.events
// 不要删除跨平台结构.
// 否则在 Java 中这个 class 不会被认为是 java.lang.RuntimeException (Kotlin bug)
@Suppress("unused")
actual class EventCancelledException : RuntimeException {
actual constructor() : super()
actual constructor(message: String?) : super(message)
actual constructor(message: String?, cause: Throwable?) : super(message, cause)
actual constructor(cause: Throwable?) : super(cause)
}