Commit 8b9cef05 authored by Him188's avatar Him188

Specify `OverFileSizeMaxException` throws

parent b0bd3d22
...@@ -579,6 +579,7 @@ internal class GroupImpl( ...@@ -579,6 +579,7 @@ internal class GroupImpl(
when (response) { when (response) {
is ImgStore.GroupPicUp.Response.Failed -> { is ImgStore.GroupPicUp.Response.Failed -> {
ImageUploadEvent.Failed(this@GroupImpl, image, response.resultCode, response.message).broadcast() ImageUploadEvent.Failed(this@GroupImpl, image, response.resultCode, response.message).broadcast()
if (response.message == "over file size max") throw OverFileSizeMaxException()
error("upload group image failed with reason ${response.message}") error("upload group image failed with reason ${response.message}")
} }
is ImgStore.GroupPicUp.Response.FileExists -> { is ImgStore.GroupPicUp.Response.FileExists -> {
......
...@@ -25,6 +25,7 @@ import net.mamoe.mirai.recall ...@@ -25,6 +25,7 @@ import net.mamoe.mirai.recall
import net.mamoe.mirai.recallIn import net.mamoe.mirai.recallIn
import net.mamoe.mirai.utils.ExternalImage import net.mamoe.mirai.utils.ExternalImage
import net.mamoe.mirai.utils.MiraiExperimentalAPI import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.OverFileSizeMaxException
import net.mamoe.mirai.utils.WeakRefProperty import net.mamoe.mirai.utils.WeakRefProperty
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext import kotlin.coroutines.EmptyCoroutineContext
...@@ -74,6 +75,7 @@ interface Contact : CoroutineScope { ...@@ -74,6 +75,7 @@ interface Contact : CoroutineScope {
* @see ImageUploadEvent 图片发送完成事件 * @see ImageUploadEvent 图片发送完成事件
* *
* @throws EventCancelledException 当发送消息事件被取消 * @throws EventCancelledException 当发送消息事件被取消
* @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时. (最大大小约为 20 MB)
*/ */
suspend fun uploadImage(image: ExternalImage): Image suspend fun uploadImage(image: ExternalImage): Image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment