mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 21:23:55 +08:00
Catch exceptions
This commit is contained in:
parent
002136eefe
commit
d6c9b9359f
@ -72,9 +72,12 @@ suspend fun main() {
|
||||
val image: Image by message
|
||||
// 等同于 val image = message[Image]
|
||||
|
||||
reply(image + " downloading")
|
||||
image.downloadTo(newTestTempFile(suffix = ".png").also { reply("Temp file: ${it.absolutePath}") })
|
||||
reply(image.id.value + " downloaded")
|
||||
try {
|
||||
image.downloadTo(newTestTempFile(suffix = ".png").also { reply("Temp file: ${it.absolutePath}") })
|
||||
reply(image.id.value + " downloaded")
|
||||
} catch (e: Exception) {
|
||||
reply(e.message ?: e::class.java.simpleName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user