浏览代码

Removes unnecessary exception handling

- Attempts to fix the below warning shown in the code. Realized there's no need for an exception handling in the first place.
- If you expect to face an exception, handle the specific exception
- TooGenericExceptionCaught
  - This rule reports catch blocks for exceptions that have a type that is too generic. It should be preferred to catch specific exceptions to the case that is currently handled. If the scope of the caught exception is too broad it can lead to unintended exceptions being caught.
Subbramanian Lakshmanan 7 年之前
父节点
当前提交
7a5430ab74
共有 1 个文件被更改,包括 3 次插入7 次删除
  1. 3 7
      app/src/main/java/com/sduduzog/slimlauncher/ui/main/MainFragment.kt

+ 3 - 7
app/src/main/java/com/sduduzog/slimlauncher/ui/main/MainFragment.kt

@@ -172,13 +172,9 @@ class MainFragment : Fragment() {
     private fun setEventListeners() {
         clockTextView.setOnClickListener {
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-                try {
-                    val intent = Intent(android.provider.AlarmClock.ACTION_SHOW_ALARMS)
-                    intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
-                    startActivity(intent)
-                } catch (e: Exception) {
-                    Log.e(TAG, e.message)
-                }
+                val intent = Intent(android.provider.AlarmClock.ACTION_SHOW_ALARMS)
+                intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
+                startActivity(intent)
             }
         }
         bottomSheet.setOnClickListener {