KotlinSyft icon indicating copy to clipboard operation
KotlinSyft copied to clipboard

Error communication should use domain objects instead of exceptions

Open mccorby opened this issue 4 years ago • 2 comments

What?

Error management in Syft is all done by exceptions. Though this is a quick solution it is becoming an antipattern.

See here https://phauer.com/2019/sealed-classes-exceptions-kotlin/

Why?

Exceptions break the normal flow of the application and force the clients to be aware of them to prevent the app crashing. Alternatives already exist providing a more robust approach as modelling the errors with sealed classes, Kotlin Result, Either or Try constructions.

Breakdown

  1. Replace exceptions in the higher levels of the lib one by one by the selected options (sealed class, Kotlin Result, Either, Try).
  2. Rinse and repeat.

Additional Context

mccorby avatar Jul 03 '20 08:07 mccorby

Please note that this is not intended to remove exceptions in the lower levels. Basically that is not possible yet. It's the lib API that should offer other mechanisms.

mccorby avatar Jul 03 '20 08:07 mccorby

#249 clears a few of these error handling

vkkhare avatar Jul 24 '20 08:07 vkkhare