The error handling in the standard packages is like this:
if err = action();err!=nil {
doErrorHandling()
}
I don't like this as it hides the action in the if statement of the
error handling. Just moving the action before the if statement won't
help. The action will still be lost between the error handling when
you have a lot of actions that can have errors.
Then I've stumbled across the blog entry http://lawlessguy.wordpress.com/2013/07/17/simulating-try-catch-in-go-golang/.
It is mainly about try-catch in go but there was one very catching
line
if dispError(err) {return }
The function is always called and it decides itself if it has to
handle an error (would return true) or not (would return false).
That way you have only one additional line per action for error
handling.