Skip to content

Commit

Permalink
Handle error when retrieving messages while archiving
Browse files Browse the repository at this point in the history
  • Loading branch information
randomnetcat committed Mar 22, 2024
1 parent c9a4295 commit 4b34bef
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main/kotlin/org/randomcat/agorabot/util/DefaultArchiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,22 @@ private suspend fun archiveChannel(
capacity = 100,
send = { messageChannel ->
withContext(Dispatchers.IO) {
channel.sendForwardHistoryTo(messageChannel)
try {
channel.sendForwardHistoryTo(messageChannel)
} catch (e: Exception) {
val errorPath = basePath.resolve("ERROR_messages.txt")
errorPath.writeText(
e.stackTraceToString(),
options = arrayOf(StandardOpenOption.CREATE_NEW)
)

// Resolve ambiguity on getId
val channelSnowflake: ISnowflake = channel
logger.error(
"Failed to get messages when archiving channel ${channelSnowflake.id}",
e
)
}
}
},
receive = { messageChannel ->
Expand Down

0 comments on commit 4b34bef

Please sign in to comment.