3 ms·
I prefer to handle errors than ignore them. "If err" is actually one of the best things about Go
by hpeter 2y ago
I prefer to handle errors than ignore them. "If err" is actually one of the best things about Go
- renegade-otter 2y agoIn most web applications I write, I have one error-handling block. Access forbidden? Log a warning and show a 403 page. Is is JSON? Then return JSON. Exception-handling in general is a pretty small part of most applications. In Go, MOST of the application is error-handling, often just duplicate code that is a nightmare to maintain. I just don't get why people insist it's somehow better, after we "evolved" from the brute-force way.
- hpeter 2y agoErrors usually happen during IO, but not in the main business logic and those two can be neatly separated. But If you are coming from java I can understand the single error handling block is more comfortable, but coming from JavaScript/Typescript it's much more easy to check if err != nil, than to debug errors I forgot to handle, during runtime.