Skip to content
0:00 / 0:00

#kotlin#errorhandling#exceptions

KotlinConf 2019: Error Handling Strategies for Kotlin Programs by Nat Pryce & Duncan McGregor

JetBrains

236K subscribers • 29 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • A classic. People kept recommending it from 2020 to 2023.
  • Presented by Nat Pryce and Duncan McGregor, software developers

Intermediate. Assumes working knowledge.

20K views6 years ago2 recommendations

Programming languagesSoftware designKotlinFunctional programmingDesign patterns

Nat Pryce and Duncan McGregor compare and contrast different error handling techniques and trade-offs in Kotlin.

Recording brought to you by American Express. americanexpress.io/kotlin-jobs Kotlin largely inherits Java's exception mechanism, but exceptions and functional programming are uneasy bedfellows, leading to most projects adopting a wing-and-a-prayer as their error handling strategy. I needn't be so ad-hoc though. In this session we compare and contrast different techniques for handling errors in Kotlin programs. We will discuss the sweet spots, pitfalls and trade-offs encountered in each technique, illustrated with examples from real projects. Resources: KotlinConf website: jb.gg/fyaze5 KotlinConf on Twitter: twitter.com/kotlinconf Kotlin website: jb.gg/pxrsn6 Kotlin blog: jb.gg/7uc7ow Kotlin on Twitter: twitter.com/kotlin #KotlinConf19 #Kotlin #JetBrains About the Presenters: Nat has been programming for *coughty-cough* years, and programming in Kotlin since it was in beta. He introduced Kotlin into his current client and his team used it to deliver business-critical, customer-facing web applications. Now many teams in the company are happy users of Kotlin, and it powers many of their core services. Duncan has been programming professionally for 25 years. He was lucky enough to ride the Object-Oriented wave of the 90s, the Agile wave of the 00s, and what he is convinced will be called the Distributed-Functional wave of the, erm 10s.

Why it's here

2 people recommend this

What people say. Recommended for its clear explanation of exception handling and algebraic data types in Kotlin.

u/dephinera_bckin r/Kotlin • Recommends

How do you define errors? I was watching the Error Handling Strategies talk from KotlinConf 2019 and they mentioned the approach I’m currently trying to apply in our project - using algebraic data types to represent the result which could be either a successful result type or an error. They also mention that when following this approach, one would either have a big error class hierarchy and therefore losing the type-checking and the exhaustiveness of handling the error, or you could have small error hierarchies based on the domain. My question is what do you do if the result you need is a combination of two or more domains, each of which has different errors that may occur? How do you def…

u/Jason5Leein r/Kotlin • Recommends

On “What's the reasoning behind Kotlins lack of enforcement of checked exceptions?”

This video made a good explanation about the problems of checked exceptions and how exception handling should be done in Kotlin.

u/DrGodCarlin r/Kotlin • Mentions

On “What tool do the presenters use in KotlinConf”

Different people use different techniques. One presenter just had Intellij in presentation mode, ASCII art title headers, and saved code snippets that would just pop into existence on demand. Another did something more mixed - some presentation-y bits then live-coding up a browser primarily driven by prepared snippets. If that's the route you want to go you really can't beat prepared snippets and detailed notes coupled with Intellij's code-collapsing in the left gutter when needed. Otherwise, screen-shot'd code blocks is another route that I'm partial to. It's less daring and exciting but it's more likely to get your point across, depending on your point.