Skip to content

Commit ab32dc8

Browse files
committed
Document checked exceptions with proxies in Kotlin
Closes gh-22412
1 parent 6089ec1 commit ab32dc8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/docs/asciidoc/languages/kotlin.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,16 @@ and https://github.com/spring-projects/spring-boot/issues/1254[`@ConfigurationPr
528528
for more details.
529529

530530

531+
=== Checked Exceptions
532+
533+
Java and https://kotlinlang.org/docs/reference/exceptions.html[Kotlin exception handling] are pretty close, with the main
534+
difference being that Kotlin treats all exceptions as unchecked exceptions. However, when using proxied objects
535+
(for example classes or methods annotated with `@Transactional`), checked exceptions thrown will be wrapped by default in
536+
an `UndeclaredThrowableException`.
537+
538+
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`]
539+
to specify explicitly the checked exceptions thrown (for example `@Throws(IOException::class)`).
540+
531541

532542
=== Annotation Array Attributes
533543

0 commit comments

Comments
 (0)