What problem I see in returning errors is that there can be many levels of such passing error around until we find a place which deals with that finally. With try catch we can just jump to the place where we handle it.
I love this too about exceptions. When my code mixes the actual logic with the error handling (if err != nil and the like), it gets very difficult to read. I like that try/catch lets the happy path flow naturally and you handle exceptions in one place.
Of course, you need to remember to handle the errors, but that's a price I'm willing to pay, rather than passing error objects around.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I love this too about exceptions. When my code mixes the actual logic with the error handling (
if err != nil
and the like), it gets very difficult to read. I like that try/catch lets the happy path flow naturally and you handle exceptions in one place.Of course, you need to remember to handle the errors, but that's a price I'm willing to pay, rather than passing error objects around.