From 2c1218870d63f74cac8195cba228a1407d614f30 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 27 Dec 2018 20:27:23 +0100 Subject: [PATCH] catch and show exceptions thrown at adding blocked numbers --- .../simplemobiletools/contacts/pro/extensions/Context.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt index 718bc412..7e1a768a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt @@ -332,7 +332,11 @@ fun Context.getBlockedNumbers(): ArrayList { fun Context.addBlockedNumber(number: String) { ContentValues().apply { put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, number) - contentResolver.insert(BlockedNumbers.CONTENT_URI, this) + try { + contentResolver.insert(BlockedNumbers.CONTENT_URI, this) + } catch (e: Exception) { + showErrorToast(e) + } } }