Transform Throwable members to properties
This commit is contained in:
committed by
Mikhail Glukhikh
parent
9088bf67c7
commit
17c906658d
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
throw Throwable("OK", null)
|
||||
} catch (t: Throwable) {
|
||||
if (t.cause != null) return "fail 1"
|
||||
return t.message!!
|
||||
}
|
||||
|
||||
return "fail 2"
|
||||
}
|
||||
@@ -3,5 +3,5 @@ class GameError(msg: String): Exception(msg) {
|
||||
|
||||
fun box(): String {
|
||||
val e = GameError("foo")
|
||||
return if (e.getMessage() == "foo") "OK" else "fail"
|
||||
return if (e.message == "foo") "OK" else "fail"
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ fun box(): String =
|
||||
"e2"
|
||||
}
|
||||
catch (e3: Exception3) {
|
||||
e3.getMessage()
|
||||
e3.message
|
||||
}
|
||||
catch (e: Exception) {
|
||||
"e"
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ fun foo(s: String): String? {
|
||||
return "no message";
|
||||
}
|
||||
catch(e: NumberFormatException) {
|
||||
return e.getMessage(); // Work around an overload-resolution bug
|
||||
return e.message // Work around an overload-resolution bug
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user