tenprint
11/09/2020, 4:34 PMRuckus
11/09/2020, 4:38 PMVampire
11/09/2020, 4:39 PMtenprint
11/09/2020, 4:41 PMVampire
11/09/2020, 4:42 PMCasey Brooks
11/09/2020, 4:50 PM@Throws
annotation https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-throws/. I don’t think it shows compiler warnings or anything, though
In general though, Kotlin discourages this as checked exceptions generally enourage poor practices with error handling. Kotlin prefers a “happy path” coding style with a centralized error handler, rather than handling or bubbling exceptions manually at every step of the data processing pipeline. If errors are expected, you should write code in a way like “if an error happens at any point, the whole pipeline fails” and the error-handling wraps the entire pipeline. Alternatively use a “Result monad” to enforce the fact that any given operation may fail and should be checked, but still allowing for the ease of “happy-path” or “railway-oriented” programming https://github.com/kittinunf/Resultnanodeath
11/09/2020, 5:52 PMIf errors are expected, you should write code in a way like “if an error happens at any point, the whole pipeline fails”this. and there might be logical places to catch or retry, too. admittedly this seems to lead to some
try-catch Exception
branches, but it's better that than a potentially long list of specific checked exceptions that are rethrown at multiple levelstenprint
11/09/2020, 6:28 PM“if an error happens at any point, the whole pipeline fails” and the error-handling wraps the entire pipelineWhat is the Kotlin construct for "pipeline"?
Flow
?nanodeath
11/09/2020, 6:33 PMtenprint
11/09/2020, 6:42 PM“if an error happens at any point, the whole pipeline fails” and the error-handling wraps the entire pipelinethis is precisely what i loved about Rx, you only had to implement the error block in your
subscribe
method and call it a day
however my org is moving away from Rx
so it would seem that a pure kotlin alternative would be Flow
, but pls let me know if there are other patterns I should check outJoost Klitsie
11/09/2020, 7:33 PM