Chris Fillmore
01/20/2022, 3:35 AMkotlin.Result
if I’m already using a custom Result type? This is my reasoning:
Pros of adopting `kotlin.Result`:
• De-duplication
• Don’t need to maintain my own type
• A portion of my code is essentially an SDK and it would be nice for its clients not to have to use my custom type, and could instead depend on Kotlin’s
• Better performance than my current type, since mine is not a value
class (though it’s probably negligible in my use case)
Cons:
• My custom type is tailored somewhat, providing additional error detail data for e.g. analytics, so I would need to create a custom Exception to carry this information
• My custom Failure type doesn’t require an exception, and so can be used for other logical failures without an exception
• More development on kotlin.Result
seems to be a no-go? (Per the KEEP https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/result.md#integration-into-the-language)
Anything I may not be considering? Also, any more detail on this:
We are working in other directions of making signalling error handling more pleasant to use in Kotlin.
Chris Fillmore
01/20/2022, 3:36 AMdave08
01/20/2022, 4:13 AMgildor
01/20/2022, 7:12 AMMy custom Failure type doesn’t require an exception, and so can be used for other logical failures without an exceptionIt looks like a different case, I think the biggest reason for Result is to encapsulate exception as return type. Result is not intended to replace all sealed/state classes which represent any kind result of operation
Chris Fillmore
01/20/2022, 4:30 PMephemient
01/22/2022, 12:09 AMgildor
01/24/2022, 3:42 AMthere are occasions where it will generate bad output for your codeIt’s also true for other value/inline class, we catch quite a lot of those isseues, but we have no problems (at least on our project) with Kotlin 1.6
ephemient
01/24/2022, 8:53 PMephemient
01/24/2022, 8:55 PMChris Fillmore
01/24/2022, 8:56 PMMarc Knaup
02/05/2022, 9:08 PM