Open stuartpa opened 1 year ago
the type of scenario I'm concerned about is partial completion of some operation where we need to clean up or roll back something on failure before the app exits. Would appropriate usage of defer
accomplish the goal? Does the deferred func still get called after checkerr
does its thing?
success := false
y := createSomeObject()
defer if !success {
y.Cleanup()
}
callMethodThatUsesCheckErr(y)
y.Commit()
success = true
Right now we inject a checkErr handler, which we use for to cope with all err return where we always expect a nil response, and let the upper layer cope with it. But this doesn't allow for nuance in error handling. But in general for a CLI there is little nuance, if something generates and err, we just bail.
Comment in PR:
"Can the app layer implementations of checkErr similar to how there can be multiple levels of a try/catch for exceptions? If there's only a global error handler referenced by checkErr then any code that needs individualized error handling isn't going to use this wrapper. "