Skip to content

Commit

Permalink
🥅 Catch errors when getting the device name
Browse files Browse the repository at this point in the history
  • Loading branch information
Importantus committed Sep 24, 2024
1 parent 5913e4e commit 50b30b6
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ fun getDeviceName(contentResolver: ContentResolver): String {
)

// Return the first non-null value
return functions.firstNotNullOfOrNull { it() } ?: "Unknown Device"
return functions.firstNotNullOfOrNull {
try {
it()
} catch (e: Exception) {
null
}
} ?: "Unknown Device"
}

0 comments on commit 50b30b6

Please sign in to comment.