Try-catch and logging

Report a typo

Try to divide by zero and catch the exception, then log it.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                Log.e("MyApp", "exception", e) // Logging the exception
              
                try {
              
                } catch (e: ArithmeticException) {
              
                val result = 10 / 0  // This will throw an exception
              
                }
              
___

Create a free account to access the full topic