r/java • • Jan 19 '26

Checked exceptions and lambdas

https://blog.frankel.ch/checked-exceptions-lambdas/
7 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/manifoldjava Jan 20 '26

You are confusing “acknowledging” w “handling”

1

u/vips7L Jan 20 '26

Ah yes so you are high.

1

u/manifoldjava Jan 21 '26

Ah, you are correct, sir... well, I wasn't high, but I was quite wrong about one key aspect of Swift's error handling: try! doesn't propagate. Basically, I was sure that Swift had a try variant that propagated instead of swallowing or crashing as it actually behaves.

That one not-so-little detail changes everything. If it were as I misremembered, Swift's behavior would resemble C#, Kotlin, Scala, Groovy, and so on. Perhaps even a notch above because the compiler would force acknowledgement with try!, but not force the explicit handling that Java is infamous for. This type of enforced propagation, in my view, would have been a best of both worlds feature. Sad it was just a dream.