Create custom exception for lateinit
This commit is contained in:
@@ -3,7 +3,7 @@ public class A {
|
||||
fun getMyStr(): String {
|
||||
try {
|
||||
val a = str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class A {
|
||||
public fun getMyStr(): String {
|
||||
try {
|
||||
val a = str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ fun box(): String {
|
||||
val a = A()
|
||||
try {
|
||||
a.str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
return "FAIL"
|
||||
|
||||
@@ -8,7 +8,7 @@ class A : Intf {
|
||||
fun getMyStr(): String {
|
||||
try {
|
||||
val a = str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
return "FAIL"
|
||||
|
||||
Reference in New Issue
Block a user