[Design] Why declare errors?
I've been a backend java dev for ~10y and a couple of years ago I moved to Kotlin because it's much better IMO in terms of syntax and it's 100% compatible with Java, as in, you can mix it together no problem. In Java there's a concept of "Runtime" and "Checked" exceptions, where you're supposed to declare all your exceptions as Checked in a method signature (there's a native spot there separate from the return type for exceptions) and then the compiler forces the calling method to either re-declare the exceptions or handle them. Runtime exceptions are stuff that you cannot predict like running out of memory and compiler doesn't force you to handle it. Kotlin is basically making a better version of java with extra features and syntax sugar as java is super-verbose, and one of the features is that they completely removed the concept of checked exceptions - everything is runtime so that compiler doesn't annoy you with handling errors where it's inappropriate.
I very much agree on that point as most of the time it actually gets in the way, especially in the context of backend, where I have a clean logic for my endpoints and a global error handler in the middleware folder. I may want to handle specific things in the logic but I can decide that and compiler doesn't interfere, I don't need to re-declare the exceptions 20 times in all my call chain.
Now that I'm getting into typescript (mainly frontend react), I just got here and it seems like a downgrade to me, going back to java. I don't know if I can just downcast the return type from
I barely got into effect, so I don't see the full picture yet, but here are my 2 cents
I very much agree on that point as most of the time it actually gets in the way, especially in the context of backend, where I have a clean logic for my endpoints and a global error handler in the middleware folder. I may want to handle specific things in the logic but I can decide that and compiler doesn't interfere, I don't need to re-declare the exceptions 20 times in all my call chain.
Now that I'm getting into typescript (mainly frontend react), I just got here and it seems like a downgrade to me, going back to java. I don't know if I can just downcast the return type from
effect<return, error> to just return but if I can that seems like it's not what your design intends, I feel like you want me to redeclare it everywhere until I handle it all. I barely got into effect, so I don't see the full picture yet, but here are my 2 cents
Stack Overflow
And how do we handle this when we are calling a method in Java which throws exceptions ?
my code is in kotlin and I am using a 3rd party library which is written in java. I call a method of this l...
my code is in kotlin and I am using a 3rd party library which is written in java. I call a method of this l...
