Lukas Lechner
08/28/2020, 8:53 AMJilles van Gurp
08/28/2020, 9:25 AMJilles van Gurp
08/28/2020, 9:34 AMExceptions should be handled by some top-level framework code of your application to alert developers of the bugs in the code and to restart your application or its affected operation. That’s the primary purpose of exceptions in Kotlin.
Jilles van Gurp
08/28/2020, 9:35 AMWhen you face an API that is using exceptions for conditions that are not logic errors for your code, then it is better to write a separate wrapper function that converts its exceptions to the appropriate return value and use this wrapper from your code. This way, your caller will have to handle the error condition right away and you avoid writingin your general application code.try/catch
Jilles van Gurp
08/28/2020, 9:37 AMJoost Klitsie
08/28/2020, 9:49 AMoshai
08/28/2020, 9:40 PMjmfayard
08/28/2020, 10:15 PMexeceptions and coroutines are easy to do wrong together
the argument is that extensive experience with Java have shown that exceptions-based code is easy to do wrong.
If you accept that premise there is no way you could add coroutines to the mix and make it hard to do wrong.
The path recommended by Roman is solid IMHO.
Money quote:
- no exception should be lost
- all bugs should get reported to developers.
- don’t use exceptions if you need local handling of certain failure scenarios in your code
- don’t use exceptions to return a result value
- avoid try/catch in general application code
- implement centralized exception-handling logic
- handle input/output errors uniformly at an appropriate boundary of your code.