4 ms·
No point in raising an error if you aren't going to do something about it. If you don't care about an error then don't check it. If you do care then handle it.
by jimjimjim 11y ago
No point in raising an error if you aren't going to do something about it.
If you don't care about an error then don't check it.
If you do care then handle it.
and you don't need massive if blocks, you can use more early returns as part of the err checks.
- dominotw 11y agoI don't exactly understand what you are suggesting. Ofcourse, I care about error and want them to be handled. Problem often is that method I am in doesn't know how to handle the error and have to bubble it up to a place where there is knowledge about how to handle it. Here is Erik Meijer talking about golang exception handling https://www.youtube.com/watch?v=a2ihmMmSfwk&t=577 https://www.youtube.com/watch?v=a2ihmMmSfwk&t=577 The golang guy doesn't answer the question properly and repeats "exceptions are not for control flow". Really disappointing answer and cringeworthy interview.