logoalt Hacker News

marcoclast Tuesday at 4:57 PM3 repliesview on HN

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?


Replies

rollcatlast Tuesday at 5:44 PM

You 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.

renewiltordlast Tuesday at 5:12 PM

Goland folds it visually partially https://github.com/golang/vscode-go/issues/2311

Refreeze5224last Tuesday at 5:03 PM

I 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.