From 8a76711fb522814c9f0e862f9692565b1885d0cc Mon Sep 17 00:00:00 2001 From: Anirban Chatterjee Date: Thu, 16 Jul 2020 00:38:26 +0200 Subject: [PATCH] Minor code refinement --- .../com/baeldung/exceptionhandling/ExceptionHandling.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/exceptionhandling/ExceptionHandling.kt b/core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/exceptionhandling/ExceptionHandling.kt index 137a303edb..225a1339e2 100644 --- a/core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/exceptionhandling/ExceptionHandling.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/exceptionhandling/ExceptionHandling.kt @@ -28,7 +28,7 @@ class ExceptionHandling { fun multipleCatchBlock(): Int? { return try { val result = 25 / 0 - return result + result } catch (exception: NumberFormatException) { println("NumberFormatException in the code") null @@ -69,10 +69,10 @@ class ExceptionHandling { } } - fun throwKeyword() { + fun throwKeyword(): Int { val message = "Welcome to Kotlin Tutorials" if (message.length > 10) throw IllegalArgumentException("String is invalid") - else println("String is valid") + else return message.length } @Throws(IOException::class)