4 ms·
Now that I think about it, are there any color schemes or extensions that highlight the error handling logic differently so that one can better focus on the “ma
by marcoc 1y ago
Now that I think about it, are there any color schemes or extensions that highlight the error handling logic differently so that one can better focus on the “main” logic flow of the code while the error handling logic is still there?
- Refreeze5224 1y agoI would love something like this, and if it exists, I've not come across it. Offloading a way of differentiating error handling syntax vs. normal code to the IDE seems like a nice way of handling this issue.
- renewiltord 1y agoGoland folds it visually partially https://github.com/golang/vscode-go/issues/2311 https://github.com/golang/vscode-go/issues/2311
- rollcat 1y agoYou would have to infer the intent of the code. One example, from a small project I'm working on: $ find . -name "*.go" | xargs grep 'if err !=' | wc -l 242 $ find . -name "*.go" | xargs grep 'if err ==' | wc -l 12 So about 5% of the error checking code is about handling the edge cases, where we are very much interested in what the error actually is, and need to handle those conditions carefully. If you discard that as "error handling noise", you're in for a bug. Which is, by the way, perhaps the worst side-effect of verbose, repetitive error handling. Apropos syntax highlighting: many themes in regular use (certainly most of the defaults) choose a low-contrast color for the comments. The comments are often the most important part of the code.