From: Lanius Trolling Date: Sat, 27 Apr 2024 14:06:57 +0000 (-0400) Subject: Handle exception when deleting potentially-nonexistent file X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=7d4e08d08fe5af859cb2617ae661616a61508830;p=factbooks Handle exception when deleting potentially-nonexistent file --- diff --git a/src/jvmMain/kotlin/info/mechyrdia/robot/RobotService.kt b/src/jvmMain/kotlin/info/mechyrdia/robot/RobotService.kt index f841195..ce01519 100644 --- a/src/jvmMain/kotlin/info/mechyrdia/robot/RobotService.kt +++ b/src/jvmMain/kotlin/info/mechyrdia/robot/RobotService.kt @@ -114,7 +114,11 @@ class RobotService( private suspend fun RobotGlobals.gcOldThreads(): RobotGlobals { for (threadId in ongoingThreadIds) - robotClient.deleteThread(threadId) + try { + robotClient.deleteThread(threadId) + } catch (ex: ClientRequestException) { + logger.warn("Unable to delete thread at ID $threadId", ex) + } return copy(ongoingThreadIds = emptySet()) } @@ -130,7 +134,11 @@ class RobotService( for ((name, text) in factbooks) { remove(name)?.let { oldId -> - robotClient.deleteFile(oldId) + try { + robotClient.deleteFile(oldId) + } catch (ex: ClientRequestException) { + logger.warn("Unable to delete file $name at ID $oldId", ex) + } } val newId = robotClient.uploadFile(