From ab32dc893785c7cb89eeb3263d9a70253efb70d4 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Sun, 17 Feb 2019 10:37:11 +0100 Subject: [PATCH] Document checked exceptions with proxies in Kotlin Closes gh-22412 --- src/docs/asciidoc/languages/kotlin.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/docs/asciidoc/languages/kotlin.adoc b/src/docs/asciidoc/languages/kotlin.adoc index c3dba7da4a..a74519b8ad 100644 --- a/src/docs/asciidoc/languages/kotlin.adoc +++ b/src/docs/asciidoc/languages/kotlin.adoc @@ -528,6 +528,16 @@ and https://github.com/spring-projects/spring-boot/issues/1254[`@ConfigurationPr for more details. +=== Checked Exceptions + +Java and https://kotlinlang.org/docs/reference/exceptions.html[Kotlin exception handling] are pretty close, with the main +difference being that Kotlin treats all exceptions as unchecked exceptions. However, when using proxied objects +(for example classes or methods annotated with `@Transactional`), checked exceptions thrown will be wrapped by default in +an `UndeclaredThrowableException`. + +To get the original exception thrown like in Java, methods should be annotated with https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-throws/index.html[`@Throws`] +to specify explicitly the checked exceptions thrown (for example `@Throws(IOException::class)`). + === Annotation Array Attributes