2 ms·
But in practice people don't do that in Go either, they just add a bunch of if error != nil lines, so you end up with no more information about what went wrong
by lmm 3y ago
But in practice people don't do that in Go either, they just add a bunch of if error != nil lines, so you end up with no more information about what went wrong (in fact less information than you'd get with an exception, since you don't even get a stack trace) and just have more clutter in your code.
- kitd 3y agoIt's not the `if err != nil` that's the problem, it's the following `return nil`. As I mention above, return instead the error with some identifying information and context, and you get highly targeted details needed to locate and fix the problem. And the way Go handles this makes it simpler than doing it via exception handling.