Skip to content

Commit 6c44d43

Browse files
committed
handle uncaught error
1 parent c5d3316 commit 6c44d43

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.intellij.openapi.components.service
1515
import com.intellij.openapi.project.Project
1616
import software.aws.toolkits.core.utils.getLogger
1717
import software.aws.toolkits.core.utils.info
18+
import software.aws.toolkits.core.utils.warn
1819
import software.aws.toolkits.core.utils.inputStream
1920
import software.aws.toolkits.jetbrains.utils.notifyStickyWithData
2021
import java.nio.file.Paths
@@ -38,12 +39,17 @@ class ProcessNotificationsBase(
3839
}
3940

4041
private fun getNotificationsFromFile(): NotificationsList? {
41-
val path = Paths.get(PathManager.getSystemPath(), NOTIFICATIONS_PATH)
42-
val content = path.inputStream().bufferedReader().use { it.readText() }
43-
if (content.isEmpty()) {
42+
try {
43+
val path = Paths.get(PathManager.getSystemPath(), NOTIFICATIONS_PATH)
44+
val content = path.inputStream().bufferedReader().use { it.readText() }
45+
if (content.isEmpty()) {
46+
return null
47+
}
48+
return NotificationMapperUtil.mapper.readValue(content)
49+
} catch (e: Exception) {
50+
LOG.warn { "Error reading notifications file: $e" }
4451
return null
4552
}
46-
return NotificationMapperUtil.mapper.readValue(content)
4753
}
4854

4955
fun retrieveStartupAndEmergencyNotifications() {

0 commit comments

Comments
 (0)