Handle exception when deleting potentially-nonexistent file
authorLanius Trolling <lanius@laniustrolling.dev>
Sat, 27 Apr 2024 14:06:57 +0000 (10:06 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Sat, 27 Apr 2024 14:06:57 +0000 (10:06 -0400)
src/jvmMain/kotlin/info/mechyrdia/robot/RobotService.kt

index f841195c98caf79318acc0586d1ecb4f2ac65ae1..ce01519226553cf4fa1b5cdc6fe8f24903aaf700 100644 (file)
@@ -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(