Skip to content

Instantly share code, notes, and snippets.

@martinbonnin
Last active September 14, 2019 23:04
Show Gist options
  • Save martinbonnin/ceaf1ad8345925dac418cbe208eec207 to your computer and use it in GitHub Desktop.
Save martinbonnin/ceaf1ad8345925dac418cbe208eec207 to your computer and use it in GitHub Desktop.
val closeable = object: Closeable {
override fun close() {
throw Exception("exception from close")
}
}
closeable.use {
throw Exception("exception from use")
}
// Java6:
// Exception in thread "main" java.lang.Exception: exception from use
// at com.example.MainKt.main(Main.kt:13)
// Java7 +:
//
// Exception in thread "main" java.lang.Exception: exception from use
// at MainKt.main(Main.kt:11)
// at MainKt.main(Main.kt)
// Suppressed: java.lang.Exception: exception from close
// at MainKt$main$closeable$1.close(Main.kt:6)
// at kotlin.io.CloseableKt.closeFinally(Closeable.kt:56)
// at MainKt.main(Main.kt:10)
// ... 1 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment